【发布时间】:2019-06-19 21:26:22
【问题描述】:
我的 TextView 有问题。我以前没有见过这个问题,谷歌也没有帮助。 我有 TextViews 和文本,它们像字符串资源一样在 xml 中定义。
<?xml version="1.0" encoding="utf-8"?>
...
<TextView
android:id="@+id/TVName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/name"
android:textSize="@dimen/textViewTextSize"
android:textStyle="bold"
android:textColor="@color/white"
android:textAllCaps="true"
android:layout_marginEnd="@dimen/marginBetweenTextViewsEnd"
android:background="@color/gray41"
/>
...
在我的代码中,我正在为此 TextView 执行 append()
public class Page extends AppCompatActivity {
TextView TVName;
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_profile);
TVName = findViewById(R.id.TVName);
TVName.append(" " + "danya");
}
}
字符串.xml
<resources>
<string name="name">Name:</string>
</resources>
我得到了一些象形文字,而不是NAME: danya,或者只是像“NAME:3ô”这样的垃圾
首先,我使用 Retrofit 从服务器获取 append() 的文本,并认为这是来自服务器的格式错误的文本,但当我尝试上面的代码时,问题再次出现。
当我在 setText() 上更改附加时 - 一切正常。
我也尝试过在 android:text="Name:" 这样的文本上更改 xml 中的字符串资源,但同样的问题。
所有文件一如往常以 UTF-8 编码且未手动编码。
【问题讨论】:
标签: android string textview append