Android 之ExpandableListView几个特殊的属性
来源:互联网 发布:js数组合并排序 编辑:程序博客网 时间:2024/06/04 18:53
1. 设置ExpandableListView 默认是展开的:
先实例化 exListView
然后
exListView.setAdapter(exlvAdapter);
//遍历所有group,将所有项设置成默认展开
int groupCount = exListView.getCount();
for (int i=0; i<groupCount; i++) {
exListView.expandGroup(i);
};
2. 去掉ExpandableListView 默认的箭头
用到ExpandableListView时有个箭头图标系统自带的在你自定义布局也不能去掉只要设置一个属性即可,如下:
settingLists.setGroupIndicator(null); ~~~~~~~~~~~~~~~~~此处就是设置自定义的箭头图标的。置空则没有了。
也可以自定义(但是位置还是在那个地方不推荐)如下:
首先,自定义一个expandablelistviewselector.xml文件,具体内容如下:
Java代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_expanded="true" android:drawable="@drawable/expandablelistviewindicatordown" />
<item android:drawable="@drawable/expandablelistviewindicator" />
</selector>
加一句代码如下:
settingLists.setGroupIndicator(this.getResources().getDrawable(R.drawable.expandablelistviewselector));
大功告成
3. 将默认的箭头修改到右边显示:
1首先 ExpandableListView elistview;
elistview.setGroupIndicator(null);//将控件默认的左边箭头去掉,
2在 自定义的继承自BaseExpandableListAdapter的adapter中有一个方法
/**
* 父类view
*/
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
Log.i("zhaoxiong","parent view");
LinearLayout parentLayout=(LinearLayout) View.inflate(context, R.layout.wowocoupons_parent_item, null);
TextView parentTextView=(TextView) parentLayout.findViewById(R.id.parentitem);
parentTextView.setText(parentlist.get(groupPosition));
ImageView parentImageViw=(ImageView) parentLayout.findViewById(R.id.arrow);
//判断isExpanded就可以控制是按下还是关闭,同时更换图片
if(isExpanded){
parentImageViw.setBackgroundResource(R.drawable.arrow_down);
}else{
parentImageViw.setBackgroundResource(R.drawable.arrow_up);
}
return parentLayout;
}
- Android 之ExpandableListView几个特殊的属性
- Android 之ExpandableListView几个特殊的属性
- Android 之ExpandableListView几个特殊的属性
- Android 之ExpandableListView几个特殊的属性
- Android 之ExpandableListView几个特殊的属性
- Android 之ExpandableListView几个特殊的属性
- Android 之ExpandableListView几个特殊的属性
- Android ExpandableListView几个特殊的属性
- Android 之ExpandableListView特殊属性
- ExpandableListView 几个特殊属性
- Android中ExpandableListView特殊属性的玩法
- ExpandableListView 的几个属性
- ExpandableListView 的几个有用点的属性
- SiteMapNode的几个特殊属性
- css特殊的几个属性
- Android之ExpandableListView的属性(Group不展开)
- Android之ExpandableListView的属性(展开,闭合,箭头)
- Android之ExpandableListView的属性(Group不展开)
- mapreduce-执行步骤详解
- 归档 及 日志 路径
- mysql学习笔记:存储过程
- 1058. A+B in Hogwarts (20)
- 静 忍
- Android 之ExpandableListView几个特殊的属性
- OpenFire源码学习之十四:插件管理
- mapreduce-combiner函数使用例子代码
- Dota相关的图片
- myeclipse 优化设置和常规设置
- 《软件方法-业务建模和需求》
- PCIe 学习笔记(三)
- Python endswith() 函数 判断字符串结尾
- 代码调试遇到的问题