jra*_*rez 8 keyboard android focus
我在一些应用程序中看到,在键盘上出现一个名为next的Button,它将焦点放在下一个Edit Text上.我想在我的应用程序中添加它,你知道我怎么做吗?或者它只在应用程序的键盘上?非常感谢.对不起,我没有更多相关信息.
sti*_*ike 14
在edittext添加android:imeOptions属性的布局中.在这里你可以添加不同的动作按钮,如Go,Search,Send,Next,Done等.但要使用这个EditText必须是singleLine Else,那里会有一个enter按钮.所以也使用了android:singleLine="true".
所以这是你的解决方案
<EditText
android:id=//put ur id
android:layout_width=//according to need
android:layout_height=//accordintoneed
android:imeOptions="actionNext"
android:singleLine="true"/>
Run Code Online (Sandbox Code Playgroud)
编辑
为了补充,我应该添加更多以供将来使用或为他人帮助..
您可以从代码中处理imeoption操作.为此你必须将setOnEditorActionListener设置为Edittext,当按下某个动作时,你可以在公共boolean onEditorAction(TextView v, int actionId, KeyEvent event)方法上获取它.如果您不自己处理代码,imeoptions操作将执行默认操作(通常转到下一个控件).
以下是处理操作的示例代码
EditText e = (EditText)findViewById(R.id.editText1);
e.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_NEXT ) {
// handle next button
return true;
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
Vaj*_*ecz 11
您只需在布局中使用imeOptions标记即可.请参阅文档中的imeOptions.
<EditText
android:id="@+id/someField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6400 次 |
| 最近记录: |