编辑 <<<<<<<<<
我发现从下面检索到的用户名返回为空。有人告诉我为什么吗?
public void getUserName() {
getUserNameDialog = new Dialog(MasterMindGameActivity.this);
getUserNameDialog.setContentView(R.layout.retrieveusername);
getUserNameDialog.setTitle("Enter your Name");
getUserNameDialog.setCancelable(false);
TextView viewScore = (TextView) getUserNameDialog
.findViewById(R.id.showScore);
viewScore.setText("Your score was " + numberOfGuesses);
final EditText enterName = (EditText) getUserNameDialog
.findViewById(R.id.userName);
btnConfirm = (Button) getUserNameDialog
.findViewById(R.id.confirmUserName);
btnConfirm.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
userName = enterName.getText().toString();
getUserNameDialog.cancel();
}
});
getUserNameDialog.show();
}
显示类似的东西
Highscore
1: null - [correct score]
其中 [正确分数] 是它应该具有的输出
为什么用户名没有被保存,而是用 null 代替?
编辑 1:修复了双重保存问题 - 现在只是 NULL 值