2

I want to show Done button in key board but this code do not works, please help me solve it. I am new to android.

My Code is:

 <EditText android:id="@+id/inputSearch"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:hint="Search jobs"
    android:gravity="center"
    android:imeOptions="actionDone"
    android:background="@drawable/edittext_bg"
    android:digits="abcdefghijklmnopqrstuvwxyz1234567890"
    android:inputType="textVisiblePassword"/>

Please help me,

Thanks in advance

user3916943
  • 61
  • 2
  • 9

4 Answers4

3

Add android:singleLine = "true" to your EditText

<EditText
            android:id="@+id/inputSearch"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="@drawable/edit_text_border"
            android:digits="abcdefghijklmnopqrstuvwxyz1234567890"
            android:gravity="center"
            android:hint="Search jobs"
            android:singleLine="true"
            android:imeOptions="actionDone"
            android:inputType="textVisiblePassword" />

Hope it works

Manishika
  • 5,478
  • 2
  • 22
  • 28
0

you are doing it in correct way but than also test it in another devices because imeOptions do not work on all devices,particularly some older ones. if you want to do this dynamically than this is the way

editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

and to track "Done" button use this code

editText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(EditText v, int actionId, KeyEvent event) {
 if (actionId == EditorInfo.IME_ACTION_DONE) {
  //do here your stuff f
  return true;
 }
 return false;
 }
});

answer from this user

for more tutorial see this link

Community
  • 1
  • 1
jaimin
  • 563
  • 8
  • 25
0

Try to use android:imeActionLabel="Next"

<EditText android:id="@+id/inputSearch"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:hint="Search jobs"
    android:gravity="center"
android:imeActionLabel="Done"
    android:imeOptions="actionDone"
    android:background="@drawable/edittext_bg"
    android:digits="abcdefghijklmnopqrstuvwxyz1234567890"
    android:inputType="textVisiblePassword"/>

Hope this will work

Android
  • 388
  • 2
  • 3
  • 14
0

I have found this issue on older devices. What has worked is to set android:inputType=""

as well as android:imeOptions="actionDone"

leeb898
  • 152
  • 2
  • 10