文件浏览器 + 优酷菜单 + 下拉菜单 + 自定义开关按钮

来源:互联网 发布:js select 设置选中项 编辑:程序博客网 时间:2024/05/16 18:19

说明:这些示例项目都是在网上或书上找到的,写在这里只为个人学习方便。

1.  文件浏览器
功能 : 实现浏览文件系统中的文件
知识点: listView + SimpleAdapter  ------ android ListView详解
效果图:
           
源码地址:android 文件浏
2.  优酷菜单
知识点:1. Animation动画
2. RelativeLayout 布局
  
源码地址:http://download.csdn.net/detail/ymangu/8038925
相似功能的博文:仿优酷圆盘菜单
3.  下拉菜单
知识点:
①.  除了其它的控件占用的位置,剩下所有的空间都给这个<TextView> ①match_parent  ②layout_weight="1"
<TextView        android:id="@+id/tv_list_item"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:gravity="center_horizontal"        android:text="@string/hello_world" />
②.  刷新 数据
    MyListAdapter.this.notifyDataSetChanged();  //当添加或删除数据后,通知它去刷新数据
③.  ListView 风格设置
listView = new ListView(this);listView.setBackgroundResource(R.drawable.listview_background); //设置listView 背景listView.setDivider(null);//设置条目之间的分隔线为nulllistView.setVerticalScrollBarEnabled(false); // 关闭垂直滚动条listView.setAdapter(new MyListAdapter());
④.  popupWindow 
popWin = new PopupWindow(MainActivity.this); popWin.setWidth(input.getWidth()); //设置宽度 popWin.setHeight(200);//设置popWin 高度  popWin.setContentView(listView); //为popWindow填充内容 popWin.setOutsideTouchable(true); // 点击popWin 以处的区域,自动关闭 popWin  popWin.showAsDropDown(input, 0, 0);//设置 弹出窗口,显示的位置

源码下载地址:http://download.csdn.net/detail/ymangu/8042109 ,效果图:

4. 自定义开关按钮
知识点:
①  invalidate();   //刷新当前视图  导致 onDraw执行
②  解决onTouch 和 onclick 的冲突问题
相似功能的博文:仿ios开关按钮 ,源码下载地址:http://download.csdn.net/detail/ymangu/8043955 ,效果图:




0 0
原创粉丝点击