例如:
String name = "hello";
R.string.other生成的定义为:public static final int other=0x7f040002;如下语句显示的结果为:hello2130968578
myTextView.setText(name + R.string.other);setText只用R.string.other作为参数可以正常显示,只用name也可以正常显示,两者组合就不行了,不知道为啥。。?怎么能正确组合显示?

解决方案 »

  1.   

    R.string.other 是整型噢,也就是数字
    name 是字符串型setText方法里的参数可以是字符串,也可以是资源ID号。
      

  2.   

    我目前想到的一种是:
    //初始化
    myTextView= (TextView) this.findViewById(R.id.other);
    //赋值
    myTextView.setText(name + myTextView.getText().toString());不知道你能不能看懂?
      

  3.   

    myTextView.setText(name + getResources().getString(R.id.other);
      

  4.   

    参考jiangyue2780的方法,先将二者拼成String,再使用即可。
      

  5.   

    getResources().getString(R.id.other);
    同样适合于取color等类似。
      

  6.   

    或者修改 <string name="other">%1$s World</string>
    String text = getString(R.string.other, name);
    myTextView.setText(text);
      

  7.   

    这个结果是hellofalse,诡异!2楼的结果是正确的。。
      

  8.   

    按你这样做是把0x7f040002强制转换成字符串了,十六进制0x7f040002=十进制2130968578,所以
    myTextView.setText(name + R.string.other)结果为:hello2130968578