與此代碼,我的計劃只是強制關閉(錯誤)我如何將一個數字/字符串存儲到R.string.xx中?
***public View x = findViewById(R.string.nfoname);***
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information);
//edittext
***final EditText infoname=(EditText)findViewById(R.id.infoname);***
//clear,confirm
Button clear = (Button)findViewById(R.id.buttonclear);
Button confirm = (Button)findViewById(R.id.buttonconfirm);
//clear button
clear.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
infoname.setText("");
}
});
//confirm button
confirm.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
***x=(View) infoname.getText();***
}
});
}
了一個與*是錯誤的來源
程序功能: 如果用戶點擊確認,他的名字將設置爲R.string.nfoname ,然後通過TextView x = setText(R.string.nfoname);
感謝, 我已經使用這個.. TextView的X =(TextView的)findViewById(); x.setText(「hello」+ getString(R.string.nfoname)); 它工作得很好,但如何設置字符串? 在我心中的一個抽象是類似於 idontknow x =(idontknow)findViewById(R.string.stringname); 這樣,只要我改變x的R.string.stringname也會改變 –
2012-01-17 02:12:33
我想這是正確的,好吧關閉研究sharedpreferences – 2012-01-17 02:45:43