现在要做的就是设置监听 监听ImageView expandableListView 的点击事件,这里我是点图片展开和关闭Child,长点击expandableListView 也展开和关闭Child,...(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { long position = ((ExpandableListView) parent...(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { long position = ((ExpandableListView) parent...(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { long position = ((ExpandableListView) parent...(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { long position = ((ExpandableListView) parent
首先我们用到的控件是:ExpandableListView 布局文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res...drawable/child_bg" 这个直接引color,或者图片会导致整个孩子背景都为这个颜色 ,不知道原因,如果有谁知道,请Give me say. --> ExpandableListView...android:groupIndicator="@null" android:scrollbarAlwaysDrawHorizontalTrack="true" > ExpandableListView...源码下载 /********************************LIstView模拟ExpandableListView**********************************...这个眨一看是ExpandableListView这个东东,可是本人比较笨戳,整了好久没有弄出来,最终放弃,google下,发现有人用listview来模拟实现,也就跟着做了下.
void setMarkerImgId(int markerImgId) { this.markerImgId = markerImgId; } } 3 如果要将自定义的数据在ExpandableListView...; public class MainActivity extends Activity { private ExpandableListView expandList; private...info = (ExpandableListView.ExpandableListContextMenuInfo)menuInfo; int type = ExpandableListView.getPackedPositionType...(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {...info = (ExpandableListView.ExpandableListContextMenuInfo)item.getMenuInfo(); switch (item.getItemId
ExpandableListView组件是android中一个比较常用的组件,当点击一个父item的时候可以将它的子item显示出来,像手机QQ中的好友列表就是实现的类似效果。...使用ExpandableListView组件的关键就是设置它的adapter,这个adapter必须继承BaseExpandbaleListAdapter类,所以实现运用ExpandableListView...; import android.widget.TextView; public class MainActivity extends Activity { private ExpandableListView...)findViewById(R.id.expandableListView1); listView.setAdapter(new MyExpandableAdapter());..." > ExpandableListView android:id="@+id/expandableListView1" android:layout_width
>> childList) { super(); this.mContext = context; this.expandableListView = expandableListView...expandableListView.isItemChecked(position)) { expandableListView.setItemChecked(position,...); mContext = ExpandableListViewTestActivity.this; expandableListView = (ExpandableListView...) this.findViewById(R.id.expandablelistview); expandableListView.setGroupIndicator(null); //...ExpandableListView的相关事件监听 // 子项选中、子项被点击、组项展开、组项被点击 // expandableListView.setOnItemSelectedListener
Android也给我们提供ExpandableListView类,完美实现这样类似的需求, 极大的方便了我们开发。结合之前的项目我们做一个简单的讲解。 首先懒看一下最终的实现效果: ?...使用到的第三方框架: AndroidAutoLayout 屏幕适配框架 代码 首先是布局需要用一个ExpandableListView,配合adapter就能实现上面额效果,直接上代码。...public class MainActivity extends AppCompatActivity { private ExpandableListView elv_collocation;...super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); elv_collocation = (ExpandableListView...private List data; public CollocationListAdapter(Context context, ExpandableListView
Android也给我们提供ExpandableListView类,完美实现这样类似的需求, 极大的方便了我们开发。结合之前的项目我们做一个简单的讲解。...使用到的第三方框架: AndroidAutoLayout 屏幕适配框架 代码 首先是布局需要用一个ExpandableListView,配合adapter就能实现上面额效果,直接上代码。...public class MainActivity extends AppCompatActivity { private ExpandableListView elv_collocation;...super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); elv_collocation = (ExpandableListView...private List data; public CollocationListAdapter(Context context, ExpandableListView
本期开始学习ExpandableListView的使用。...一、认识ExpandableListView ExpandableListView 是 ListView 的子类,它在普通ListView的基础上进行了扩展,它把应用中的列表项分为几组,每组里又可包含多个列表项...ExpandableListView的用法与普通 ListView的用法非常相似,只是 ExpandableListView所显示的列表项应 该由 ExpandableListAdapter 提供。...二、ExpandableListView 示例 接下来通过一个简单的示例程序来学习ExpandableListView的使用方法。...设置Adapter,并为ExpandableListView设置事件监听器。
ExpandableListView是android中可以实现下拉list的一个控件,具体的实现方法如下: 首先:在layout的xml文件中定义一个ExpandableListView expandableListView" android:layout_width="fill_parent" android:layout_height=...添加上Adapter ExpandableListView expandableListView = (ExpandableListView)findViewById(R.id.expandableListView...=ExpandableListView.getPackedPositionGroup(menuInfo.packedPosition); int childPos =ExpandableListView.getPackedPositionChild...(menuInfo.packedPosition); 二、ExpandableListAdapter 一个接口,将基础数据链接到一个ExpandableListView。
(原创)转载请声明出处https://cloud.tencent.com/developer/user/1148436/activities 问题原型: ExpandableListView...--------------------直接看结论请拉置 红线下------------------- 早在同年5月份的时候我写过一篇 自定义 ExpandableListView 收缩类的...直到今天,本来想做个日程表,考虑到月份是可选的,所以想重新使用 ExpandableListView,逐使用之。...我们知道使用 ExpandableListView 要为它配置个 数据是配置器,也就是ExpandableListAdapter,它有9个接口函数要求重写,具体请转至我的的专题介绍了解它:http://...button 的存在导致 ExpandableListView 一级目录可点击性失效。这真是天坑,马上百度百度,看看有没有相同案例,百度了才发现,有碰到和我相同问题的,但是都没有解决!!!
这几天公司写个电商项目,写道购物车页面,发现ExpandableListView点击子类的方法无效!!
新来的产品提了一个需求,让应用中的一个列表按照分类显示,并且能提示当前是在哪个分类,度娘了一番,参考了前辈们的博客,实现了如下图的效果: 效果图.gif 这种效果的实现这里是采用自定义ExpandableListView...一 项目结构 项目结构.PNG 上边儿三个类分别是我们的自定义ExpandableListView,主界面,以及ExpandableListView使用的Adapter。...下边儿几个xml文件分别是主界面布局,指示器布局,ExpandableListView子项布局,ExpandableListView组布局。...二 实现代码 1.在xml中声明自定义ExpandableListView <test.com.expandablelistviewdemo.CustomExpandListview //这里不唯一...() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view,
一 ExpandableListView基本介绍 ExpandableListView是Android中的一个可扩展列表视图,它继承自ListView,并提供了支持展开和折叠的功能。...以下是对ExpandableListView的一些基本特性和用法: 数据源:ExpandableListView需要一个适配器(ExpandableListAdapter)来提供数据源。...二 ExpandableListView使用方法 在 XML 布局文件中添加 ExpandableListView: ExpandableListView android:id="@+id/...ExpandableListView expandableListView = findViewById(R.id.expandableListView); // 创建适配器 MyExpandableListAdapter...adapter); // 设置分组项点击事件监听器 expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener
这里就用ExpandableListView+GridView,如果有人不了解这个ExpandableListView的话,看完这篇基本用法就会了。...步骤: 总布局的创建,里面只要一个ExpandableListView控件。 ExpandableListView的item布局创建,本布局用最传统的做法分为Group和Child布局。...ExpandableListView适配器创建。 数据加载。 查看效果图,这个图在上传的时候压缩了就变的模糊了,请谅解。 ?...1: 总布局的创建,里面只要一个ExpandableListView控件。 这里文件非常简单,只有一个控件,当然ExpandableListView也是有很多属性的。...适配器创建 适配器的创建才是重点,首先我们对ExpandableListView自定义适配器,然后再在里面嵌套一个GridView的自定义适配器,当然你也可以调用系统的,不过个人觉得自定义有更好的灵活性
ExpandableListView 一、实现效果 二、实现步骤 1.编写父布局parent.xml 2.编写子布局child.xml 3.编写适配器类GradeAdapter 三、解析适配器类 一...、实现效果 ExpandableListView又称可扩展的ListView,简单来说长这个样: 每一个一级布局下面又可以展开二级布局。...二、实现步骤 使用ExpandableListView主要有三个步骤: 编写父布局 编写子布局 适配器的书写 1.编写父布局parent.xml 父布局其实很简单,就是两个并排的TextView,用于展示课程名字和分数...id="@+id/tv_teacher" style="@style/item_child_grade" /> 3.编写适配器类GradeAdapter 一般适用于ExpandableListView...布局代码也很简单,只要有一个ExpandableListView就好了: ExpandableListView android:id="@+id/expand_lv" android:layout_margin
废话不说先上效果: 实际上这是采用一个ExpandableListView实现的 布局文件很简单: ExpandableListView组件--> ExpandableListView android:id="@+id/list" android:...layout_width="match_parent" android:layout_height="match_parent"> ExpandableListView> expandableListView = (ExpandableListView) findViewById(R.id.list); expandableListView.setOnChildClickListener...(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
ChildLists.add(childLists3); 2.把准备好的一级二级数据传入adapter ... mExpandableListView = dialogView.findViewById(R.id.expandablelistview...mExpandableListView.setAdapter(moAdapter); ... 3.监听点击事件 //一级选项点击回调 mExpandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener...() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition...//更新选中状态 return false; } }); //二级选项点击回调 mExpandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener...() { @Override public boolean onChildClick(ExpandableListView parent, View v, int reverseTypePosition
可折叠列表ExpandableListView 嵌套列表ExpandableListView是又一种常见的控件,常见的业务场景包括:好友分组与好友列表、订单列表与订单内的商品列表、邮件夹分组与邮件列表等等...ExpandableListView常用方法 Android自带的ExpandableListView可以直接用于嵌套列表,点击一个组,展开该组下的子列表;再点击这个组,收起该组下的子列表。...下面是ExpandableListView的常用方法说明: setAdapter : 设置适配器。...ExpandableListView监听器 除了OnItemClickListener,ExpandableListView新加了下面几个监听器: 1、分组展开事件,相关类名与方法说明如下:...ExpandableListView常见问题 ExpandableListView有时会发现子项不会响应点击事件,这可能是某个环节没有正确设置。
ExpandableListView,是ListView的子类。本质上是一个AdapterView,既然是AdapterView,在显示数据的时候,就需要使用到适配器。...-- 主界面就是可扩展列表;android:groupIndicator="@null" 取值可以是任意的Drawable对象,不再显示groupIndicator --> ExpandableListView...----- initView();// 这个是自定义的方法 } private void initView() { expand_list_id=(ExpandableListView...() { @Override public boolean onGroupClick(ExpandableListView expandableListView...() { @Override public boolean onChildClick(ExpandableListView expandableListView
match_parent" android:background="@color/target_divider_color" android:orientation="vertical"> ExpandableListView...} } }); //二级 mSecondListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener...() { @Override public boolean onGroupClick(ExpandableListView expandableListView...return true; } }); mSecondListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener...() { @Override public boolean onChildClick(ExpandableListView expandableListView
领取专属 10元无门槛券
手把手带您无忧上云