使用此代码
EditText editetext = (EditText) findViewById(R.id.editetext); // change this R.id.editetext to your EditText id
Button doneButton = (Button) findViewById(R.id.doneButton); // change this R.id.doneButton to your Button id
doneButton .setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = Integer.parseInt(editetext.getText.toString);
}
});
更新
试试这个在键盘上完成按钮操作
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// do any thing here
}
return false;
}
});