由网友(空长叹)分享简介:我用的一些应用程序在那里,当我填写了用户名,然后进入我的密码,如果我打完成,登录表单自动提交,在键盘上没有我不得不点击提交按钮。这是怎么做的?I've used some apps where when I fill my username, then go to my password, if I hit "Don...
我用的一些应用程序在那里,当我填写了用户名,然后进入我的密码,如果我打完成,登录表单自动提交,在键盘上没有我不得不点击提交按钮。这是怎么做的?
I've used some apps where when I fill my username, then go to my password, if I hit "Done" on the keyboard, the login form is automatically submitted, without me having to click the submit button. How is this done?
推荐答案
试试这个:
在你的布局认沽/编辑这样的:
In your layout put/edit this:
<EditText
android:id="@+id/search_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:singleLine="true"
android:imeOptions="actionDone" />
在你的活动把这个(例如,在的onCreate):
In your activity put this (e. g. in onCreate):
// your text box
EditText edit_txt = (EditText) findViewById(R.id.search_edit);
edit_txt.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
submit_btn.performClick();
return true;
}
return false;
}
});
其中,的submit_btn
与您的onclick处理程序连接您的提交按钮。
Where submit_btn
is your submit button with your onclick handler attached.
相关推荐
最新文章