<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />我现在只能显示  hello_world 把hello_world换成其它文字就报错,求什么原因!
纠结啊!Androidtextview

解决方案 »

  1.   

    我换成
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/abc" />
    都不行!是不是装的有问题?
      

  2.   

    android:text="@string/hello_world" 这个的意思是 显示的是  你工程下的 res目录下的values下的String中的  hello_word对应的字符。你光改了hello_world,那程序就到你工程下的 res目录下的values下的String中找你修改的那个标识对应的字符,你没有定义,自然找不到。(这个类似于一个变量的引用,你没有定义这个变量,在代码里就不能使用)有两种修改办法:
    最简单的:把@string/hello_world  整个换掉,譬如换成  hello android  如android:text="hello android"
    第二种,在res目录下的values下的String文件中模仿hello_world,定义另外一个字符串,另起一个名字,再把这句改为android:text="@string/你定义的字符串标识",这样就没问题了
      

  3.   


    这么写
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="abc" />
    就好了
      

  4.   

    @string/hello_word  string是values中的资源,/后面的内容是string资源的名字而不是要显示的内容。找到res包中String文件,打开找到对应的名字,然后更改要显示的内容即可。text属性不建议用。