0

我在可扩展列表视图组的右侧有一个图像。我希望当我单击图像时,这会展开 de 组,但是当我单击图像时,它什么也不做。

我的 onCreate 中有这段代码,我不知道这是否必须在可扩展列表适配器中。

    /*****************************************************************/
// Elementos del layout
        expLista = getExpandableListView();
        expLista.setItemsCanFocus(true);
        expLista.setOnGroupClickListener(new OnGroupClickListener() {

            @Override
            public boolean onGroupClick(ExpandableListView parent, View v,
                    int groupPosition, long id) {
                grupoCLickeado = groupPosition;
                ImageView btnExpandir = (ImageView) v
                        .findViewById(R.id.imgExpandir);
                btnExpandir.setFocusable(false);
                btnExpandir.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        expLista.expandGroup(grupoCLickeado, true);
                    }
                });
                expLista.setOnGroupExpandListener(new OnGroupExpandListener() {

                    @Override
                    public void onGroupExpand(int groupPosition) {
                        expLista.collapseGroup(groupPosition);
                        codigoServicio = numerosServicios.get(groupPosition);
                    }

                });

                return false;
            }
        });
4

1 回答 1

0

而不是使用OnGroupExpandListener您必须使用setOnGroupClickListener

取而代之的是,

expLista.setOnGroupExpandListener(new OnGroupExpandListener() {

                @Override
                public void onGroupExpand(int groupPosition) {
                    expLista.collapseGroup(groupPosition);
                    codigoServicio = numerosServicios.get(groupPosition);
                }

            });

用这个,

expLista.setOnGroupClickListener(new OnGroupClickListener() {

                @Override
            public boolean onGroupClick(ExpandableListView parent, View v,
                        int groupPosition, long id) {

                        expLista.collapseGroup(groupPosition);
                        return true;
                    }
                    return true;
                }
            });
于 2012-06-06T12:02:56.957 回答