由EditText上的自定义ListAdapter失去焦点叫了两声 [英] Custom ListAdapter consisting of EditText lose focus called twice

查看:177
本文介绍了由EditText上的自定义ListAdapter失去焦点叫了两声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个电子商务应用程序,其车列表中有一个自定义的ListView 这是由的EditText 的。项目的的EditText 重新presents的数量。我使用 OnFocusChangeListener 当客户完成改变,然后更新服务器上的车项目的数量来检测。一切正常,只是 onFocusChange 被调用两次即我越来越的两倍。

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.

推荐答案

添加下面一行到你的活动清单解决了这一问题:

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

 android:windowSoftInputMode="adjustPan"

不知道为什么,虽然。

Not sure why though.

这篇关于由EditText上的自定义ListAdapter失去焦点叫了两声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆