Insert a single view inside a listview makes listItem non clickable

I am inflating a view inside a list item on listItemClick .The list item contains a check box. When the check box is clicked a linear layout containing two/three edit text fields and buttons gets inflated to that list view ( done by getView method of cursor adapter, the inflating view is dynamically created ) .

the list view is registered with on item click listener . After the layout being inflated , the onItemClick Listener is not getting called for the particular item. Help me

my getView code

TextView text1  = (TextView) view.findViewById (R.id.text);
        text1.setText("text");

        CheckBox cb = (CheckBox)view.findViewById(R.id.checkBoxList) ;
        cb.setTag(tag);
        cb.setChecked(false);

        if ( chekedIdVector.contains(cursor.getString(cursor.getColumnIndex(ID) )))
        {
            cb.setChecked(true);
        }

        if( !idVector.isEmpty () )
        {
            LinearLayout ll =(LinearLayout)view.findViewById(R.id.layoutinCell);

            if ( ((String)idVector.lastElement()).equals(cursor.getString(cursor.getColumnIndex(_ID) )) )
            {

                if (ll.getChildCount() == 0 )
                {
                    ll.removeAllViews() ;
                    ll.addView(dynamicallyCreatedView); // view dynamically created with 2/3 textviews and buttons
                }

                ll.setVisibility(View.VISIBLE); 
                view.requestFocus() ;
            }

            else
            {
                ll.removeAllViews() ;
            }
        }

        return view  ;

Ps: I have tried on focus changed listener and set the check box to non focusable in xml


如果一切都失败了,可以考虑使用ExpandableListView(http://developer.android.com/reference/android/widget/ExpandableListView.html)或者从android:visibility =“GONE”开始充气项目,然后设置它作为“可见”而不是膨胀它们。

链接地址: http://www.djcxy.com/p/30554.html

上一篇: 如何更改在列表视图中单击的项目的图像资源

下一篇: 在listview中插入单个视图使listItem不可点击