R.string中的资源不能修改,但是如何能和其他string组合使用
R.string中的资源不能修改,但是怎么能和其他string组合使用?
例如:
String name = "hello";
R.string.other生成的定义为:public static final int other=0x7f040002;
如下语句显示的结果为:hello2130968578
myTextView.setText(name + R.string.other);
setText只用R.string.other作为参数可以正常显示,只用name也可以正常显示,两者组合就不行了,不知道为啥。。?
怎么能正确组合显示?
------解决方案--------------------
我目前想到的一种是:
//初始化
myTextView= (TextView) this.findViewById(R.id.other);
//赋值
myTextView.setText(name + myTextView.getText().toString());
不知道你能不能看懂?
------解决方案--------------------
myTextView.setText(name + getResources().getString(R.id.other);
例如:
String name = "hello";
R.string.other生成的定义为:public static final int other=0x7f040002;
如下语句显示的结果为:hello2130968578
myTextView.setText(name + R.string.other);
setText只用R.string.other作为参数可以正常显示,只用name也可以正常显示,两者组合就不行了,不知道为啥。。?
怎么能正确组合显示?
------解决方案--------------------
我目前想到的一种是:
//初始化
myTextView= (TextView) this.findViewById(R.id.other);
//赋值
myTextView.setText(name + myTextView.getText().toString());
不知道你能不能看懂?
------解决方案--------------------
myTextView.setText(name + getResources().getString(R.id.other);