-2

How to disable EditText searchview after completion of input on fragment?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Kitereative Indonesia
  • 1,097
  • 6
  • 19
  • 39
  • Have you called the method visibility from the class? "searchView.setVisibility(View.GONE);" – El0din Dec 22 '17 at 08:05
  • Its work, i want when I hit enter on searchview input text, I want to disable the input text and set the input result in the action bar. If the user wants to re-enter, then the user just press X (clear) icon in the top panel to the right – Kitereative Indonesia Dec 22 '17 at 08:53

2 Answers2

0

You can set View.OnFocusChangeListener to your editText and after focus change call setEnabled(false). for eg.

mEditText.setOnFocusChangeListener(new OnFocusChangeListener() { 
@Override 
public void onFocusChange(View view, boolean hasFocus) {
    if (hasFocus) {
      //let the user input
    } else { 
        //disable you search view

        mEditText.setEnabled(false);


    } 
} 
}); 

P.S. -If you are still facing a problem, please update your code snippet.

Goku
  • 9,102
  • 8
  • 50
  • 81
Fatal Exception
  • 167
  • 2
  • 12
0

If user have to click button after enter text into searchview, you can handle this in event button click method. In your button click method you can write:

search.setEnabled(false);
qubuss
  • 268
  • 3
  • 12