Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText focus lost

Tags:

android

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?

like image 539
nidhi Avatar asked Dec 27 '22 18:12

nidhi


2 Answers

Focusable EditText inside ListView

like image 194
DEVANG SHARMA Avatar answered Feb 01 '23 01:02

DEVANG SHARMA


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
        }
    }
});
like image 28
macloving Avatar answered Feb 01 '23 03:02

macloving