- 浏览: 376411 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 1181自定义的dialog没有全屏的解决办法: AlertD ... -
Android中计算textView长度问题
2012-10-18 17:54 5725http://zilla.blog.51cto.com/309 ... -
控件宽高
2012-10-18 11:38 876imageView = (ImageView)findVie ... -
多级树形菜单的实现_expandlist
2012-10-17 17:17 808多级树形菜单的实现_expandlist http: ... -
适应多行长文本的Android TextView
2012-09-18 21:14 1037适应多行长文本的Android TextView ht ... -
ListView的右边滚动滑块
2012-09-03 18:09 3246ListView的右边滚动滑块: XML布局只需要在L ... -
设置Scrollview滚动位置
2012-09-03 09:51 1312appViewContent.post(new Runnabl ... -
ScrollView中的组件设置android:layout_height=fill_parent不起作用的解决办法
2012-08-31 11:01 1621ScrollView中的组件设置android:layout_ ... -
ScrollView反弹效果的实现
2012-08-22 11:39 1821转载:http://www.eoeandroid.com/th ... -
viewpager
2012-07-23 14:28 1949Android ViewPager多页面滑动切换以及动画效果 ... -
search搜索框
2012-07-05 12:50 752转载: 动态修改android内置搜索对话框(浮动搜索 ... -
仿iphone滑动开关按钮实现
2012-06-25 15:24 2556转载: http://www.apkbus.com/foru ... -
android仿iphone滚轮效果实现
2012-06-25 15:19 1676转载:android仿iphone滚轮效果实现 htt ... -
能够兼容ViewPager的ScrollView
2012-06-25 13:03 13441转载:http://www.strongcms.net/mob ... -
viewpager Android实现导航菜单左右滑动效果
2012-06-19 16:02 7042http://blog.csdn.net/xiedantibu ... -
纵向GALERY
2012-06-07 16:11 770纵向GALERY收藏: -
listview的item点击无反应
2012-06-04 13:56 1078用于处理在listview中加入某些控件后,控件和Listvi ... -
edittext判断输入字符长度
2012-05-29 10:00 14735转载: http://blog.csdn.net/li ... -
edittext
2012-05-21 11:40 801EditText继承关系:View-->TextView ... -
relativelayout
2012-05-21 11:38 878// 相对于给定ID控件 android:layout_ ...
相关推荐
ExpandListView在我们开发中使用非常常见,但原生的ExpandListView往往会达不到我们使用的效果,我们会以两个例子为例来理解ExpandListView,现在我们看下如何做呢?blog:...
2级菜单Expandlistview http://blog.csdn.net/s611533106/article/details/45126755
主要用于Expandlistview的下拉刷新
有动画的expandlistview,类似于点开分组分的时候所有别的分组向下挤的效果
android实现多层展开的功能,使用的是expandlistview嵌套
用RecyclerView写的ExpandListView,当然处理形式是以Adapter的变化来处理。
ExpandListView自定义下拉刷新和上拉加载更多
GroupName滑动到顶端时会固定不动直到另外一个GroupName到达顶端的ExpandListView,支持快速滑动,支持Android2.3及以上
利用ExpandListView集成BaseExpandListView重写各种方法设置对应布局实现个性化的二级列表界面新颖优美.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
来源github,带展开动画的expandlistview,注意在activity中使用setongroupclicklisener
ExpandListView滑动到顶端时固定.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
ExpandListView具体实现
异步加载 仿expandListView效果 分页异步加载 仿expandListView效果 分页异步加载 仿expandListView效果 分页异步加载 仿expandListView效果 分页
这是一款有好多种二级菜单的项目。有类似美团上的美食购物分类,有类似QQ分组的,有listview里面嵌套gridview的。几乎项目中个能用到的二级菜单这里都有,而且界面还是比较简洁的,很实用,又得直接可以在项目中应用...
Andriod ExpandListview和checkbox的结合,里面还涉及到动态添加View,ExpandListview每个条目下checkbox的数目不同,而且在ExpandListview合上后还能保持自己的状态
android-pinned-header-listviews,expandlistview集团.zip
有趣的ExpandListView.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
扩展的自定义listview控件[ExpandListview.rar]-精品源代码