Need a previous and next button above the keypad

后端 未结 3 642
感动是毒
感动是毒 2021-01-06 12:39

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

相关标签:
3条回答
  • 2021-01-06 12:51

    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.

    0 讨论(0)
  • 2021-01-06 12:52
    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;
            }
        });
    
    0 讨论(0)
  • 2021-01-06 13:09

    You can set proper IME option for the Edittext in the Layout.

    android:imeOptions="actionNext"
    

    and for done

    android:imeOptions="actionDone"

    0 讨论(0)
提交回复
热议问题