你好,我正在关注学习Android的书籍教程,但这本书已经过时了。我得到一个“不能翻译的字符串文字”和“不要连接文本与setText”。我想知道什么是更新TextView的正确方法?我认为这就是我基本上想要做的。如何正确更新textView?
<TextView
android:id="@+id/textScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Score: 999"
android:textSize="36sp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/textOperator"
android:layout_toStartOf="@+id/textOperator" />
<TextView
android:id="@+id/textLevel"`enter code here`
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Level: 4"
android:textSize="36sp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="11dp"
android:layout_marginEnd="11dp" />
这里是Java。
textObjectScore.setText("Score:" + currentScore);
textObjectLevel.setText("Level:" + currentLevel);
如果你创建了一个'String textToSet =“Score:”+ currentScore;'then textObjectScore.setText(textToSet);'? –