如何显示变量的屏幕上的值 [英] How to display the value of a variable on the screen

查看:476
本文介绍了如何显示变量的屏幕上的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是很基本的,但我需要知道我怎么能在屏幕上显示一个变量的内容。

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

难道我在布局中使用一个TextView?

Do I use a textview in my layout?

我有一个TextView盒子,我可以将其设置为说,在编辑器的东西,但我需要写一个变量的内容,所以我可以做一些错误检查。

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.

谁能帮助?

感谢

推荐答案

如果你在你的布局XML文件中定义了一个名为textViewName TextView的,你可以做这样的事情在你Activity类:

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");

这是你在找什么?如果你不需要它显示到屏幕上,而只是想调试,只使用Log(),并以logcat中查看邮件。

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.

这篇关于如何显示变量的屏幕上的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆