我想用键盘上方的Prev,Next按钮显示虚拟键盘。需要键盘上方的上一个按钮和下一个按钮
当用户点击上一个按钮时,光标应该移到上一个编辑文本输入字段,点击下一个按钮应该进入视图中下一个编辑文本字段。
我想在我自己的活动中使用这些按钮。我怎样才能做到这一点?
我想用键盘上方的Prev,Next按钮显示虚拟键盘。需要键盘上方的上一个按钮和下一个按钮
当用户点击上一个按钮时,光标应该移到上一个编辑文本输入字段,点击下一个按钮应该进入视图中下一个编辑文本字段。
我想在我自己的活动中使用这些按钮。我怎样才能做到这一点?
这可以通过将android:windowSoftInputMode =“adjustPan”添加到清单中的活动 元素来实现。例如。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codename.android"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/MyTheme"
>
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
这可以防止在显示虚拟键盘时调整视图的大小。
您可以在布局中为Edittext设置适当的IME选项。
android:imeOptions="actionNext"
并做
机器人:imeOptions = “actionDone”
Android code to override the "Done" button in my EditText field:
myEditField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm =(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindowToken(), 0);//hide the keyboard.
return true;
}
return false;
}
});
可以覆盖的onkeydown()方法。 –