android – EditText onFocusChanged listener for listView array adapter-ThrowExceptions

Exception or error:

I am having an issue with EditText losing focus when I do notifyDataChanged() in a ListView array adapter. So, based on the research, some say that onFocusChanged() listener can be used to tackle this problem. Can anybody give me a code example?

Seems like you need to check if the focus is lost on the current edid Text and use a variable to keep track and get the focus back.

I have tried the XML way it did not help, so not that answer.

How to solve:

Here goes your example:

editText.setOnFocusChangeListener(new OnFocusChangeListener() {          
        public void onFocusChange(View v, boolean hasFocus) {

Also, add these attributes to your EditText, if you already haven’t:


Also, you might need to add android:descendantFocusability="afterDescendants" to your listview.

Leave a Reply

Your email address will not be published. Required fields are marked *