布局:
....
<EditText
....
android:hint="@string/email"
android:imeOptions="actionSend"/>
<Button
...
android:onClick="sendMessage" <<<- both must call it
android:text="@string/send" />
然后在代码中绑定:
( (EditText) findViewById(R.id.email) ).setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
sendMessage(findViewById(android.R.id.content));
return false;
}
});
sendMessage 在哪里
public void sendMessage(View view)
{
....
intent.putExtra("email", getEditContent(R.id.email));
startActivityForResult(intent, 0);
}
当我按下按钮时,一切都很好。当我在 imeOption (键盘)中按“完成”时,两个活动同时开始。
我究竟做错了什么?