How to disable EditText searchview after completion of input on fragment?
Asked
Active
Viewed 949 times
-2

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 Answers
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
-
Sorry sir, i want if 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:54
-
You can see this question it may be useful as per your requirement. [link](https://stackoverflow.com/questions/33294731/custom-search-in-android) – Fatal Exception Dec 22 '17 at 10:57
-
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