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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With