expandablelistview响应onGroupClick监听:设置expandablelistview.setOnGroupClickListener()
折叠和展开事件,可以设置setOnGroupCollapseListener和setOnGroupExpandListener
ExpandableListView中包含多个group,想要展开一个group时,其他group都关闭:
3.expandablelistview的Group点击事件,onGroupClick的返回值false展开,true不展开
折叠和展开事件,可以设置setOnGroupCollapseListener和setOnGroupExpandListener
ExpandableListView中包含多个group,想要展开一个group时,其他group都关闭:
- exList.setOnGroupExpandListener(new OnGroupExpandListener() {
- @Override
- public void onGroupExpand(int groupPosition) {
- for (int i = 0; i < getData().size(); i++) {
- if (groupPosition != i) {
- exList.collapseGroup(i);
- }
- }
- }
- });
- tt_list.setOnGroupClickListener(new OnGroupClickListener() {
- @Override
- public boolean onGroupClick(ExpandableListView parent, View v,
- int groupPosition, long id) {
- IsFlag=true;
- if(adapter.getGroupData().get(groupPosition).getList().size()==1){
- Bundle b=new Bundle();
- b.putInt("saveIndex", 0);
- // b.putString("mac", mac);
- // b.putString("deviceId", mDeviceId);
- b.putSerializable("datalist", adapter.getGroupData().get(groupPosition).getList());
- Intent i=new Intent(WappushBindingActivity.this,VideoPlayerActivity.class);
- i.putExtras(b);
- startActivity(i);
- }
- // int groupCount = tt_list.getCount();
- // for (int i=0; i<groupCount; i++){
- // if(i!=GroupPosition)
- // tt_list.collapseGroup(i);
- // };
- // Log.v("xulongheng*WappushBind*tt_list", "onGroupClick:"+previousX+"/"+previousY);
- return true; //默认为false,设为true时,点击事件不会展开Group
- }
- });