Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the value of a variable on the screen?

Tags:

I know this is very basic question, but I need to know, how I can display the contents of a variable on the screen.

Do I use a textview in my layout?

I have a textview box and I can set it to say something in the editor but I need to write the contents of a variable so I can do some error checking.

Anyone help?

like image 799
MrCloister Avatar asked Apr 28 '11 15:04

MrCloister


People also ask

How do you display the value of a variable?

Here are three ways to display multiple variable values on the same line in the Command Window. Concatenate multiple character vectors together using the [] operator. Convert any numeric values to characters using the num2str function. Use disp to display the result.

Which function is used to display value of a variable?

The printf routine is the most commonly used routine in this book. This is because it provides an easy and convenient means to display program results. Not only can simple phrases be displayed, but the values of variables and the results of computations can also be displayed.

Which command should I use to display a variable?

The echo command is useful to display the variable's output especially when you know the content of a variable will not cause any issue.

How do I see variable values in Visual Studio?

Add a variable to a Watch windowRight-click the variable in the data tip, and select Add Watch. The variable appears in the Watch window. If your Visual Studio edition supports more than one Watch window, the variable appears in Watch 1.


1 Answers

If you have a TextView named textViewName defined in your layout XML file, you can just do something like this in your Activity class:

setContentView(R.layout.layoutName); TextView textView = (TextView) findViewById(R.id.textViewName); textView.setText("text you want to display"); 

Is this what you're looking for? If you don't need to display it to the screen, and just want to debug, just use Log() and logcat to view the messages.

like image 79
Matt Avatar answered Sep 29 '22 00:09

Matt