2

I am working with Amazon S3 api.

Problem: Working with TextWatcher. As soon as user enters more than 3 characters in the edittext, api is called and it shows matched results. The problem starts as soon the user hit the done/enter button on soft keyboard, the api is called again and it searches again. Can i stop this second call somehow? Thanks!

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
Hashir Ali
  • 191
  • 2
  • 10

5 Answers5

4

you can change it from xml:

<EditText
...
android:imeOptions="actionNone"/>

or from code:

editText.setImeOptions(EditorInfo.IME_ACTION_NONE);

It will remove the done button whenever user trigger the softkeybord

Antoine El Murr
  • 317
  • 1
  • 13
0

Maybe you can try to override the onKeyListener method in your control, to let it detect if the key pressed is 'enter' and add the code you want your 'enter' key to do ?

edittext.setOnKeyListener(new View.OnKeyListener() {

0

just handle done click and hide the soft keyboard

editText = (EditText) findViewById(R.id.edit_text);

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
           // hide your keyboard here
           try {
                   InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
                   if (inputMethodManager != null && activity.getCurrentFocus() != null) {
             inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
                   }
           } catch (Exception e) {
             e.printStackTrace();
           }
           return true;
        }
        return false;
    }
});
Sumit Jain
  • 1,100
  • 1
  • 14
  • 27
0

Add

android:maxLines="1"

to you xml and enter button should be disabled.

COYG
  • 1,538
  • 1
  • 16
  • 31
0

You can Do like editText.setImeOptions(EditorInfo.IME_ACTION_NONE);

but it won't hide the Enter/Next

Vignesh
  • 355
  • 1
  • 4
  • 17