开发者

Android - extending setOnGroupExpandListener method

I am using an ExpandableListView. It works fine, but I want to add an OnGroupExpandListener; The problem is if I override it, the 'basic' default behaviour for that is overridden as well. I basically want something like this:

        mTeamListAdapter = new TeamListAdapter(getLayoutInflater());
        mTeamList =  (ExpandableListView) findViewById(R.id.screen_team_teamslist);
        mTeamList.setAdapter(mTeamListAdapter);
        mTeamList.setGroupIndicator(null);
        mTeamList.setOnGroupExpandListener(new OnGroupExpandListener() {

            @Override
            public void onGroupExpand(int groupPosition) {
                // do my stuff..
                // something like "super();" to enable the other default behaviour  
            }

        });

开发者_运维问答Specifically, I want to make a Button visible (and clickable - it is "android:visibility="gone" before) on each group in the ExpandableListView. I still want each group, and its children, to be clickable as well! How do I do this?

EDIT: By "basic default behaviour", I mean that if I override that method (OnGroupExpand) it seems I cannot expand/collapse the groups anymore!


The assertion that "the 'basic' default behaviour is overridden" when an OnGroupExpandListener is set is not correct.

You can verify it by looking at the source code for ExpandableListView (see the handleItemClick method):

http://codesearch.google.com/codesearch#uX1GffpyOZk/core/java/android/widget/ExpandableListView.java&q=package:android.git.kernel.org%20file:android/widget/ExpandableListView.java&l=1

Are you sure you haven't set a OnGroupClickListener? This WILL override group expansion if its OnGroupClick implementation returns true (i.e. the click is deemed to be handled).

Either that, or something in your specific OnGroupExpand implementation is affecting the data that your ExpandableListAdapter uses to display the child rows for the groups.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜