4

In a custom ListView, there are two columns, one contains a TextView and the other a EditText component.To enter some preferences, as the user clicks on the EditText, the software keyboard comes in focus but focus from the EditText is lost. How I can do this?

a2800276
  • 3,272
  • 22
  • 33
nidhi
  • 73
  • 1
  • 1
  • 5

2 Answers2

6

Focusable EditText inside ListView

Community
  • 1
  • 1
DEVANG SHARMA
  • 2,662
  • 5
  • 33
  • 52
4

For editText use method setFocusable(false). For textView use setFocusable(true).

Also write a listener on focus lost for both textView and editText:

textView.setOnFocusChangeListener(new OnFocusChangeListener() {          

    public void onFocusChange(View v, boolean hasFocus) {
        if(!hasFocus)
        {
           //do job here when EditText loses focus
        }
    }
});
Guillermo GutiƩrrez
  • 17,273
  • 17
  • 89
  • 116
macloving
  • 1,227
  • 1
  • 18
  • 22