1. 设置ExpandableListView 默认是展开的: 
先实例化exListView 然后

    exListView.setAdapter(exlvAdapter);
//遍历所有group,将所有项设置成默认展开
intgroupCount = exListView.getCount();
for (inti=; 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.layout.expandablelistviewselector));
或xml设置:
android:groupIndicator="@drawable/groupIndicator_selector"

3. 将默认的箭头修改到右边显示: 
 
1首先ExpandableListViewelistview;

elistview.setGroupIndicator(null);//将控件默认的左边箭头去掉,

2在自定义的继承自BaseExpandableListAdapter的adapter中有一个方法

    /** * 父类view */ 
   @Override
public View getGroupView(intgroupPosition, booleanisExpanded, View convertView, ViewGroup parent)
{ Log.i("zhaoxiong","parent view");
LinearLayoutparentLayout=(LinearLayout) View.inflate(context, R.layout.wowocoupons_parent_item, null);
TextViewparentTextView=(TextView)parentLayout.findViewById(R.id.parentitem);
parentTextView.setText(parentlist.get(groupPosition));
ImageViewparentImageViw=(ImageView) parentLayout.findViewById(R.id.arrow);
//判断isExpanded就可以控制是按下还是关闭,同时更换图片
if(isExpanded){
parentImageViw.setBackgroundResource(R.drawable.arrow_down);
}else{
parentImageViw.setBackgroundResource(R.drawable.arrow_up); }
return parentLayout;
}

expandablelistview响应onGroupClick监听:设置expandablelistview.setOnGroupClickListener()
折叠和展开事件,可以设置setOnGroupCollapseListener和setOnGroupExpandListener

ExpandableListView中包含多个group,想要展开一个group时,其他group都关闭:

    exList.setOnGroupExpandListener(new OnGroupExpandListener() {    

            @Override
public void onGroupExpand(int groupPosition) {
for (int i = ; 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()==){
Bundle b=new Bundle();
b.putInt("saveIndex", );
// 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的属性(Group不展开)的更多相关文章

  1. 使用ExpandableListView——当有Group选项展开时,如何正确获取长按的Group选项。

    当我们使用ExpandableListView时,实现点击一个GroupView则展开ChidView,那么这个时候,Adapter的大小前后是有变化的. 例如:假设有20个GroupView,每个G ...

  2. Android开发 ExpandableListView 可折叠列表详解

    前言 在需要实现一个List的item需要包含列表的时候,我们就可以选择ExpandableListView. 其实这个View的原始设计还是ListView的那套.就是增加2层的ListView而已 ...

  3. android 之 ExpandableListView列表中的列表

    有时候,我们需要设计这样一个界面,外面有一个列表,当我们点击其中列表中的某个条目时,就会展开这个条目,出现一个新的列表.比如下图:(程序运行的效果图,在这里贴出来) 当我们点击第一项时,视图变为: - ...

  4. Android中ExpandableListView控件基本使用

    本文採用一个Demo来展示Android中ExpandableListView控件的使用,如怎样在组/子ListView中绑定数据源.直接上代码例如以下: 程序结构图: layout文件夹下的 mai ...

  5. Android在ExpandableListView控制的基本使用

    在本文中,Demo为了展示Android在ExpandableListView用途管制.如该组/儿子ListView绑定数据源. 直接上代码例如以下: 程序结构图: layout文件夹下的 main. ...

  6. android中xml tools属性详解

    第一部分 安卓开发中,在写布局代码的时候,ide可以看到布局的预览效果. 但是有些效果则必须在运行之后才能看见,比如这种情况:TextView在xml中没有设置任何字符,而是在activity中设置了 ...

  7. android中xmlns:tools属性详解

    今天读到一篇总结的非常棒的文章,写的逻辑很清晰也很实用,很少见到如此棒的文章了.就原文转发过来,我把格式给整理了一下,分享给园子里的各位朋友!好久没写博客了,就为2015年的11月留份纪念吧.希望对你 ...

  8. 22.Android之ExpandableListView树形列表学习

    Android经常用到树形菜单,一般ExpandableListView可以满足这个需要,今天学习下. XML代码: <?xml version="1.0" encoding ...

  9. Android之ExpandableListView

    ExpandableListView可以用来表现多层级的listView,本文主要是ExpandableListView的一个简单实现 布局文件 <LinearLayout xmlns:andr ...

随机推荐

  1. [转]The culture name list in C#

    Culture Names [C#] This example shows how to get all culture names in the .NET Framework. Use static ...

  2. Windows 注册表操作

    经常操作注册表,然后得到一份操作注册表函数实现.这里备份下. #ifndef _REGEDIT_H #define _REGEDIT_H int RegRead_S (struct HKEY__*Re ...

  3. MYSQL存储过程和函数学习笔记

    学至Tarena金牌讲师,金色晨曦科技公司技术总监沙利穆课程笔记的综合. 1. 什么是存储过程和函数 将SQL语句放入一个集合里,然后直接调用存储过程和函数来执行已经定义好的SQL语句,通过存储过程和 ...

  4. hdu4893Wow! Such Sequence! (线段树)

    Problem Description Recently, Doge got a funny birthday present from his new friend, Protein Tiger f ...

  5. tstring

      是的,一旦知道 TCHAR 和_T 是如何工作的,那么这个问题很简单.基本思想是 TCHAR 要么是char,要么是 wchar_t,这取决于 _UNICODE 的值: // abridged f ...

  6. 完全卸载sql2005

    转自:http://www.cnblogs.com/mytechblog/articles/1883961.html 1.Stop 所有服务 2.在控制面板中卸载所有与SQL Server 2005相 ...

  7. Java基础知识强化46:StringBuffer类之判断一个字符串是否对称案例

    1. 分析:判断一个字符串是否是一个对称的字符串,我们只需要把字符串的第1个字符和最后1个字符,第2个字符和倒数第2个字符,…… 比较的次数是长度除以2.  方法1:通过取取索引对应值来进行一一比对 ...

  8. C# winform xml的增删改查

    代码如下: using System; using System.Collections.Generic; using System.IO; using System.Linq; using Syst ...

  9. 通过 yum update 将系统从CentOS 6.2 升级到 CentOS 6.6 及升级过程中的简单排错

    本文说明 本文写于2014年的WP中,后WP停止维护,今天翻到此记录整理下,记录于此,方便日后查看. 话说那时候写博客真是认真啊~哈哈~ 升级前的系统信息 [root@thatsit ~]# unam ...

  10. 在iOS虚拟机上使CLPlacemark获取中文信息

    -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ CLLocat ...