如何在控件Button写属性Text

比如:

<Button

    android:id="@+id/btnce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/CE"


最初写的是android:text="CE"
总是提示要用@string resouces,并不明白该怎么弄。
上网搜资料,发现,有两种方式:
1.快捷键:在text后面按Alt+Enter,会出现提示,然后在出来的对话框里定义字符串变量并初始化。
2.找到string.xml这个文件,在其中定义字符串变量。
找的方式如下:


(。。。不要在意标红的,是有文件出错了)
定义格式如下:


经验:还是不要被无知吓到吧,莫慌

猜你喜欢

转载自www.cnblogs.com/mo-sheng/p/9862297.html