When I add a view to a ListView item, that item no longer responds

I want a new one Viewappears in mine ListView Itemif I click this item like this where (1) and (2) clicks

enter image description here

and I can do it, but when I want to click this one again Item, that is, hide this new one View, then it Itemno longer clicks on how it should be.

I perform the addView operation in my onItemClickListenerright to the right position

My code is as follows

...
list_view.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.i("TAG", "onItemClick:: BEGIN");

            switch (position) {
                case 0 : 
                    Log.i("TAG", "onItemClick:: before addTitle");                      
                    showFieldList(view);
                    Log.i("TAG", "onItemClick:: after  addTitle");
                break;              
                ...                 
            }

            Log.i("TAG", "onItemClick:: END");
        }
});
...

I tried to show the behavior in mine Logand after the first click I can see my LogEntry "TAG" with the values

onItemClick:: BEGIN

onItemClick:: before addTitle

onItemClick:: after addTitle

onItemClick:: BEGIN

, , Item , client_adapter Log, , getGroupView Method, , Item,

, , OnGroupExpand/OnGroupCollapse/OnGroupClick Listeners ExpandableListView.

: ListView, , , ExpandableListView, , , , ExpandableListView .

- , Item , ExpandableListView FieldList? !

    private View showFieldList(View view) {

        // Retrieving Item Layout. (= view Layout)
        RelativeLayout item_layout = (RelativeLayout) view.findViewById(R.id.relLayoutDrawer);

        // Retrieving "title" Element
        TextView title_tv = (TextView)view.findViewById(R.id.title);

        View row = View.inflate(context, R.layout.field_list, null);

        // Getting Field names
        Resources res = getResources();
        String fields = res.getString(R.string.fields);         

        client = (ExpandableListView)row.findViewById(R.id.field_expandable_list);

        client.setFocusable(false); //<< ADDED TO WORK  

        client_adapter = new ClientAdapter(context, fields);



        // When I comment this Line, `onItemClick` works
        // if not, then client_adapter assummes control

        client.setAdapter(client_adapter); 

        // Setting "Subtitle" under "title" aligning both left borders
        params.addRule(RelativeLayout.ALIGN_LEFT, title_tv.getId());
        params.addRule(RelativeLayout.BELOW, title_tv.getId());     
        item_ayout.addView(row, params);    
    }

drawer_list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relLayoutDrawer"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@android:color/black">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="25dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/title"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:contentDescription="@string/desc_list_item_icon" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_toRightOf="@id/icon"
        android:minHeight="?android:attr/listPreferredItemHeightSmall"
        android:textAppearance="?android:attr/textAppearanceListItemSmall"
        android:textColor="@color/metallic_silver"
        android:gravity="center_vertical"
        android:paddingRight="40dp"/>

    <TextView android:id="@+id/counter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@layout/counter_bg"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="8dp"/>

</RelativeLayout>
+4
2

!

onCollapsedGroupListener, onExpandedGroupListener onClickedGroupListener,

client = (ExpandableListView)row.findViewById(R.id.field_expandable_list);
...
client.setFocusable(false);
+3

, ExpandableListView, ListView. ExpandableListView , ListView onClick, , onClick, ListView .

: ListView OnItemClickListener ?

, momo, - ExpandableListView .

+3

All Articles