Custom ListAdapter consisting of EditText lose focus called twice

android, android-edittext, android-listview, listener

Solution

Adding the following line into your activity in the manifest fixed the problem:

 android:windowSoftInputMode="adjustPan"

Not sure why though.

Problem

I am making a E-commerce app whose cart list has a custom `ListView` which consist of `EditText`. The `EditText` represents the quantity of item. I am using `OnFocusChangeListener` to detect when a customer is done changing the quantity of the item then updating the cart on server. Everything is working fine, just the `onFocusChange` is being called twice i.e. I am getting `false` twice. ``` viewHolder.etProductQuantity.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if(!hasFocus){ // Updating the ProductList class's object to set the new quantity // Updating product quantity on server Log.d("Product Quantity", viewHolder.etProductQuantity.getText().toString() + b); } } }); ``` Thus, the coding is being executed twice which is creating problem.

Original source