有人能帮助我,我听到很多东西,我不知道该相信什么。我正在制作一个应用程序,它是一个计数器。在我的xml布局中,我有一个TextView作为计数器,文本由strings.xml中的字符串设置,我控制文本视图在我的java文件中说的内容。这里有一些代码片断它。所有我想知道的是这个好吗?,它工作正常,但我想知道这是一个坏的或好的方法。android改变文本视图(这段代码是否正确?)
"counter" equals a variable.
"display" is referencing the ID of the textview"
what i am using to control the text view.
display.setText(String.valueOf(counter));
here is my text view in my xml layout
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tvDisplay"
android:gravity="center"
android:text="@string/counter"
android:textSize="20dp" />
here is the string in strings.xml
<string name="counter">0</string>
好吧,感谢您的帮助和时间,我总是喜欢被告知我在正确的轨道上。我只想问你,如果你不介意回答,就像你说的“如果有一个TextView的小值,那么你可以直接给android:text =”abcd“,如果我这样做会标记一个警告所以我只是使用一个字符串变量,或者你正在试图说的是忽略这个警告,因为它的无害,以及你做事情的方式是好的,所以为了最好的使用就像继续你一样。帮帮我。 – 2012-01-02 09:33:43