- 浏览: 384903 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
longxishui12:
这个一定要顶得高高的。
[Android UI界面] android中仿iphone实现listview的反弹效果 -
klower.jiang:
Good job, Thank you so much!
能够兼容ViewPager的ScrollView -
ZSRTFAT:
...
file size 的大小计算
expandlistview的DEMO,来自网络。
for (int i = 0; i < 5; i++) { Map<String, String> curGroupMap = new HashMap<String, String>(); groupData.add(curGroupMap); curGroupMap.put(G_TEXT, "Group " + i); List<Map<String, String>> children = new ArrayList<Map<String, String>>(); for (int j = 0; j < 5; j++) { Map<String, String> curChildMap = new HashMap<String, String>(); children.add(curChildMap); curChildMap.put(C_TEXT1, "Child " + j); curChildMap.put(C_TEXT2, "Child " + j); } childData.add(children); } adapter = new ExAdapter(ExListView.this); exList = (ExpandableListView) findViewById(R.id.list); exList.setAdapter(adapter); exList.setGroupIndicator(null); exList.setDivider(null); exList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { Log.d("test", "onChildClick" + "childPosition" + childPosition); Log.d("test", "onChildClick" + "groupPosition" + groupPosition); return false; } }); exList.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { Log.d("test", "onGroupExpand"); Log.d("test", "onGroupExpand" + "groupPosition" + groupPosition ); } });
class ExAdapter extends BaseExpandableListAdapter { ExListView exlistview; public ExAdapter(ExListView elv) { super(); exlistview = elv; } public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.member_listview, null); } TextView title = (TextView) view.findViewById(R.id.content_001); title.setText(getGroup(groupPosition).toString()); ImageView image = (ImageView) view.findViewById(R.id.tubiao); if (isExpanded) image.setBackgroundResource(R.drawable.btn_browser2); else image.setBackgroundResource(R.drawable.btn_browser); return view; } public long getGroupId(int groupPosition) { return groupPosition; } public Object getGroup(int groupPosition) { return groupData.get(groupPosition).get(G_TEXT).toString(); } public int getGroupCount() { return groupData.size(); } // ************************************** public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.member_childitem, null); } final TextView title = (TextView) view .findViewById(R.id.child_text); title.setText(childData.get(groupPosition).get(childPosition).get( C_TEXT1).toString()); final TextView title2 = (TextView) view .findViewById(R.id.child_text2); title2.setText(childData.get(groupPosition).get(childPosition).get( C_TEXT2).toString()); if(childData.get(groupPosition).size() == 1){ }else if(childData.get(groupPosition).size() > 1){ if(childData.get(groupPosition).size() % 2 == 0){ //偶数 if(childPosition == 0){//white up Log.d("test", "偶数white up"); }else if(childPosition == childData.get(groupPosition).size() - 1){ //black down Log.d("test", "偶数black down"); }else if((childPosition + 1) % 2 != 0){//white nomal Log.d("test", "偶数white nomal"); }else if((childPosition + 1) % 2 == 0){//black normal Log.d("test", "偶数black normal"); } }else if(childData.get(groupPosition).size() % 2 != 0){ if(childPosition == 0){//white up Log.d("test", groupPosition + "奇数white up" +childPosition); }else if(childPosition == childData.get(groupPosition).size() - 1){ //white down Log.d("test", groupPosition + "奇数white down"+childPosition); }else if((childPosition + 1) % 2 != 0){//white nomal Log.d("test", groupPosition + "奇数white nomal"+childPosition); }else if((childPosition + 1) % 2 == 0){//black normal Log.d("test", groupPosition + "奇数black normal"+childPosition); } } } return view; } public long getChildId(int groupPosition, int childPosition) { return childPosition; } public Object getChild(int groupPosition, int childPosition) { return childData.get(groupPosition).get(childPosition).get(C_TEXT1) .toString(); } public int getChildrenCount(int groupPosition) { return childData.get(groupPosition).size(); } // ************************************** public boolean hasStableIds() { return true; } public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } }
转载:
http://www.linuxidc.com/Linux/2011-08/41349.htm
客户提出需求,要求分组列表单击一个group其他的group应该关闭,这个group的group标题应该顶头。
我网上大致找了一圈没找到相关的,于是去google group里搜索了下 ,发现有人提出了他的解决方法:
受此启发我想出了自己的方法,重写setOnGroupClickListener方法,使用flag控制:
定义flag记录列表状态
int expandFlag = -1;//控制列表的展开 重写onGroupClick方法 1.ExpandableListView listView = getExpandableListView(); 2. 3.listView.setOnGroupClickListener(new OnGroupClickListener() { 4. 5. @Override 6. public boolean onGroupClick(ExpandableListView listView, View v, 7. int groupPosition, long id) { 8. 9. if (expandFlag == -1) { 2. //展开被选的group 3. listView.expandGroup(groupPosition); 4. //设置被选中的group置于顶端 5. listView.setSelectedGroup(groupPosition); 6. expandFlag = groupPosition; 2. } else if (expandFlag == groupPosition) { 3. listView.collapseGroup(expandFlag); 4. expandFlag = -1; 5. } else { 6. listView.collapseGroup(expandFlag); 7. //展开被选的group 8. listView.expandGroup(groupPosition); 9. //设置被选中的group置于顶端 10. listView.setSelectedGroup(groupPosition); 11. expandFlag = groupPosition; 12. } 13. 14. return true; 15. } 16.}); 本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2011-08/41349.htm
自己修改的:
mApplicationsList.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView listView, View v,int groupPosition, long id) { TGLog.d("__groupPosition__expandFlag_" + groupPosition + "|" + expandFlag); if(groupPosition == 0){ behDB.addOneBehCount("1806", 3); }else if(groupPosition == 1){ behDB.addOneBehCount("1801", 3); } //实现:分组列表单击一个group其他的group应该关闭,这个group的group标题应该顶头。 if (expandFlag == -1) { // 展开被选的group if(mApplicationsList.isGroupExpanded(groupPosition)){ listView.collapseGroup(groupPosition); }else { if(groupPosition == 1){ listView.collapseGroup(0); listView.expandGroup(groupPosition); }else if(groupPosition == 0){ listView.expandGroup(groupPosition); listView.collapseGroup(1); } } // 设置被选中的group置于顶端 listView.setSelectedGroup(groupPosition); expandFlag = groupPosition; } else if (expandFlag == groupPosition) { if(mApplicationsList.isGroupExpanded(groupPosition)){ listView.collapseGroup(expandFlag); }else { if(groupPosition == 1){ listView.collapseGroup(0); listView.expandGroup(groupPosition); }else if(groupPosition == 0){ listView.expandGroup(groupPosition); listView.collapseGroup(1); } } expandFlag = -1; } else { if(mApplicationsList.isGroupExpanded(groupPosition)){ listView.collapseGroup(expandFlag); }else { // 展开被选的group if(groupPosition == 1){ listView.collapseGroup(0); listView.expandGroup(groupPosition); }else if(groupPosition == 0){ listView.expandGroup(groupPosition); listView.collapseGroup(1); } } // 设置被选中的group置于顶端 listView.setSelectedGroup(groupPosition); expandFlag = groupPosition; } return true; } });
转载:
http://k-beta.com/android-learning-expandablelistview-contact.html
ExpandableListView listView = getExpandableListView(); listView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView listView, View v, int groupPosition, long id) { if (expandFlag == -1) { //展开被选的group listView.expandGroup(groupPosition); //设置被选中的group置于顶端 listView.setSelectedGroup(groupPosition); expandFlag = groupPosition; } else if (expandFlag == groupPosition) { listView.collapseGroup(expandFlag); expandFlag = -1; } else { listView.collapseGroup(expandFlag); //展开被选的group listView.expandGroup(groupPosition); //设置被选中的group置于顶端 listView.setSelectedGroup(groupPosition); expandFlag = groupPosition; } return true; } });
转载:
http://v5browser.iteye.com/blog/1728386
- ExListView.rar (411.4 KB)
- 下载次数: 13
发表评论
-
dialog全屏的问题
2012-11-02 15:43 1220自定义的dialog没有全屏的解决办法: AlertD ... -
Android中计算textView长度问题
2012-10-18 17:54 5761http://zilla.blog.51cto.com/309 ... -
控件宽高
2012-10-18 11:38 901imageView = (ImageView)findVie ... -
多级树形菜单的实现_expandlist
2012-10-17 17:17 837多级树形菜单的实现_expandlist http: ... -
适应多行长文本的Android TextView
2012-09-18 21:14 1081适应多行长文本的Android TextView ht ... -
ListView的右边滚动滑块
2012-09-03 18:09 3274ListView的右边滚动滑块: XML布局只需要在L ... -
设置Scrollview滚动位置
2012-09-03 09:51 1338appViewContent.post(new Runnabl ... -
ScrollView中的组件设置android:layout_height=fill_parent不起作用的解决办法
2012-08-31 11:01 1647ScrollView中的组件设置android:layout_ ... -
ScrollView反弹效果的实现
2012-08-22 11:39 1852转载:http://www.eoeandroid.com/th ... -
viewpager
2012-07-23 14:28 1977Android ViewPager多页面滑动切换以及动画效果 ... -
search搜索框
2012-07-05 12:50 793转载: 动态修改android内置搜索对话框(浮动搜索 ... -
仿iphone滑动开关按钮实现
2012-06-25 15:24 2585转载: http://www.apkbus.com/foru ... -
android仿iphone滚轮效果实现
2012-06-25 15:19 1703转载:android仿iphone滚轮效果实现 htt ... -
能够兼容ViewPager的ScrollView
2012-06-25 13:03 13480转载:http://www.strongcms.net/mob ... -
viewpager Android实现导航菜单左右滑动效果
2012-06-19 16:02 7072http://blog.csdn.net/xiedantibu ... -
纵向GALERY
2012-06-07 16:11 820纵向GALERY收藏: -
listview的item点击无反应
2012-06-04 13:56 1104用于处理在listview中加入某些控件后,控件和Listvi ... -
edittext判断输入字符长度
2012-05-29 10:00 14772转载: http://blog.csdn.net/li ... -
edittext
2012-05-21 11:40 837EditText继承关系:View-->TextView ... -
relativelayout
2012-05-21 11:38 909// 相对于给定ID控件 android:layout_ ...
相关推荐
ExpandListView在我们开发中使用非常常见,但原生的ExpandListView往往会达不到我们使用的效果,我们会以两个例子为例来理解ExpandListView,现在我们看下如何做呢?blog:...
标题“2级菜单Expandlistview”恰好描述了这个控件在实现多级菜单时的应用。在这个教程中,我们将深入探讨ExpandableListView的工作原理以及如何使用它来创建一个具有二级菜单的界面。 ExpandableListView是...
在Android开发中,ListView是一种常用的组件,用于展示大量的列表数据,而ExpandListView是ListView的一个扩展,它支持子项的展开和折叠,使得显示更丰富的信息。这个压缩包"安卓listview相关相关-ExpandListView...
在Android开发中,ExpandListView是一种常用的控件,它允许用户展开和折叠子项,从而提供更丰富的信息展示。本文将详细讲解如何实现ExpandListView的自定义下拉刷新和上拉加载更多的功能,这对于构建动态加载数据的...
"expandlistview 加入动画效果"就是这样一个需求,它指的是为ExpandableListView添加特定的动画,例如当一个分组被展开时,其他分组会向下平滑地移动,这种效果就像水波纹扩散一样,给予用户更为直观和舒适的视觉...
本项目"expandlistview多层展开Android-TreeView-原版"旨在实现多层展开的功能,通过嵌套`ExpandableListView`来达到这一目标。 `ExpandableListView`是Android SDK提供的一种可扩展的列表视图,它不仅支持单个条目...
而“expandlistview的下拉刷新”是指为这个控件添加下拉刷新功能,使得用户在顶部拉动时可以更新数据。下拉刷新在移动应用中非常常见,为用户提供了一种便捷的方式来获取最新的内容。 实现`ExpandableListView`的...
总结来说,使用`RecyclerView`实现`ExpandListView`功能,主要涉及到自定义`Adapter`、处理点击事件、管理布局以及优化性能等方面。这种实现方式具有更高的灵活性,可以根据项目需求定制更多复杂的功能,同时也能...
"带展开动画的expandlistview"是GitHub上一个开源项目,它在ExpandableListView的基础上添加了动态展开和折叠的动画效果,提升了用户体验。 这个项目的核心在于`AnimatedExpandableListView`,它继承自Android原生...
在Android开发中,ExpandListView是一种常用的控件,它允许用户展开和折叠子列表项,为用户提供了一种层次化的数据展示方式。本实例将详细介绍如何在实际应用中实现ExpandListView的功能。 首先,理解...
利用ExpandListView集成BaseExpandListView重写各种方法设置对应布局实现个性化的二级列表界面新颖优美.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
而ExpandListView是ListView的一个扩展,它增加了可折叠/展开子项的功能,使得用户可以对列表中的某一项进行展开以显示更多详细内容,这种设计常用于层级结构的数据展示,如菜单、目录等。 在"有趣的ExpandListView...
异步加载 仿expandListView效果 分页异步加载 仿expandListView效果 分页异步加载 仿expandListView效果 分页异步加载 仿expandListView效果 分页
在Android开发中,ExpandListView是一种常用的控件,它允许用户展开和折叠子列表项,非常适合用来展示层次结构的数据。在“仿通讯录的ExpandListView的GroupName悬停”这个主题中,我们关注的是如何实现一种类似...
在Android开发中,`ExpandListView`是一个非常常用的控件,它允许我们展示可折叠的列表项,即子项可以通过点击父项来展开或收起。本文将深入探讨如何实现`ExpandListView`的自动更新功能,这在数据动态变化时特别...