I want to show the virtual keyboard with Prev, Next Buttons above the keyboard.
When the user clicks prev button, cursor should move to the previous edit-text input
This can be achieve by adding android:windowSoftInputMode="adjustPan" to activity element within the manifest. E.g.
<?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>
This prevents the view from resizing when the virtual keyboard is displayed.
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;
}
});
You can set proper IME option for the Edittext in the Layout.
android:imeOptions="actionNext"
and for done
android:imeOptions="actionDone"