http://blog.csdn.net/u011733020/article/details/51002746
多条件筛选菜单,在020app 上类似选地区,选择类型等功能。 一般早先来说,都是用popupwindow 去实现这个功能。 但其实原生的布局去实现这样一个功能同样是可以的,并且可以扩展定制样式。 基本所有的菜单,都可以归纳为以上两类:1 Listview(单列) 2 Gridview(多列)
以下两种效果,第一种效果 跟第二种效果,实现方式大同小异。区别仅仅在于ListView 与GridView。
接下来,根据思路去看一下实现过程。
功能介绍:点击顶部的菜单栏,弹出菜单选择栏,选择具体菜单条目后,记录当前选择条目,并关闭菜单选择栏,将该选择条目展示在当前菜单栏上。
思路分析:给顶部的菜单栏添加点击事件,当响应点击事件时,弹出 菜单选择栏,给菜单选择栏的item 记录点击事件,将该item的信息传递出去保存,并改变item选择状态,同事隐藏 菜单选择栏。
首先去实现这一个布局
[html] view plain copy
接下来是下面的菜单选择栏:
[html] view plain copy
由于默认是隐藏的,所以我们记得设置Visible 属性。
接下来就是在Activity去操作了,比较简单,就做了两件事,
1 注册点击事件
[java] view plain copy
2 给listview 适配数据
[java] view plain copy
然后在handler 的 handlemessage 方法中去做响应的处理:
[java] view plain copy
第二种效果同理,只要将listview 替换成Gridview,只贴一下布局, Activity中代码基本一致。
[java] view plain copy