我创建了一个“hello world”Android 项目,我想在MainActivity.java中使用我的字符串。在string.xml文件中,我有一个名为的字符串password
如何将此字符串调用到我的MainActivity.java?
<string name="password">Your password is:</string>
MainActivity.java的一部分
....
....
//Show password on click
showBTN.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//i want to use a string called from string.xml instead of hard coded
resTXT.setText("Your password is:"+ pass);
}
});
....
....