我正在使用Hello World应用程序进行Android应用程序开发,但是我无法在Android模拟器中看到输出。模拟器屏幕上只会显示Android,并且我只是打印“Hello from Brijesh”,但它不会在Android模拟器中显示。实际上,我按照以下链接中的说明操作。
http://developer.android.com/guide/tutorials/hello-world.html
但没有得到输出结果。有没有人可以帮帮我呢?
谢谢。
如果我理解正确,您想将一些调试信息输出到屏幕上吗?在标准的Java中,您可以使用System.out.println方法,但对于Android,建议您使用Dalvik调试器。
使用:
Log.i("mytag","My simple message");
你可以使用Dalvik调试监视器来查看输出:
使用以下命令启动Dalvik调试监视器:
c:\android-sdk\tools\ddms.bat
只需将文件夹名称更改为您安装SDK的位置。
现在调试器应用程序将启动(位于模拟器旁边),并且您的消息将显示为绿色文本。
ddms
已被弃用,请使用tools/monitor
代替。 - sherb您还可以通过创建一个包含“System.out”的日志标记的过滤器,在Dalvik Debug Monitor或LogCat中查看System.out.println命令。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
/>
如果你想使用Java打印它,那么:
TextView tv = new TextView(this);
//Set a text into view
tv.setText("Hello World");
//set the view into activity view container
setContentView(tv);