android 中ExpandableListView的一些功能设置
来源:互联网 发布:调查问卷统计软件 编辑:程序博客网 时间:2024/05/21 20:30
先实例化exListView 然后
exListView.expandGroup(groupPosition);
2. 去掉ExpandableListView 默认的箭头
用到ExpandableListView时有个箭头图标系统自带的在你自定义布局也不能去掉只要设置一个属性即可,如下:
settingLists.setGroupIndicator(null); ~~~~~~~~~~~~~~~~~此处就是设置自定义的箭头图标的。置空则没有了。
也可以自定义(但是位置还是在那个地方不推荐)如下:
首先,自定义一个expandablelistviewselector.xml文件,具体内容如下: Java代码
settingLists.setGroupIndicator(this.getResources().getDrawable(R.layout.XXXX));
或者设置:android:groupIndicator="@drawable/groupIndicator_selector"
3. 将默认的箭头修改到右边显示:
1首先ExpandableListViewelistview;
elistview.setGroupIndicator(null);//将控件默认的左边箭头去掉,
2在自定义的继承自BaseExpandableListAdapter的adapter中有一个方法
getGroupView()方法中,//判断isExpanded就可以控制是按下还是关闭,同时更换图片if(isExpanded){
parentImageViw.setBackgroundResource(R.drawable.arrow_down);
}else{
parentImageViw.setBackgroundResource(R.drawable.arrow_up);
}
expandablelistview响应onGroupClick监听:设置expandablelistview.setOnGroupClickListener()
折叠和展开事件,可以设置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); } } }});3.expandablelistview的Group点击事件,onGroupClick的返回值false展开,true不展开
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 } });
- android 中ExpandableListView的一些功能设置
- android ExpandableListView的功能解析
- android 为ExpandableListView中child设置监听器
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- Android中ExpandableListView的使用
- android中expandablelistview的学习
- Android中ExpandableListView的使用
- Android中ExpandableListView的用法
- IV-Before the Interview
- break和continue区别
- UVa-11300 - Spreading the Wealth(中位数)
- JAVA学习方向总结
- Django链接远程数据库并创建model
- android 中ExpandableListView的一些功能设置
- 浅谈sql常见语法
- npm install 报错chromedriver 记录
- git
- 高级组合技打造chm后门
- 通过Eclipse(CDT)使用OpenCV
- 构建基于Spring4的Rest API
- LTE PWS CMAS CBS msg
- SGI STL容器概述