7 Android UI组件使用2

7 Android UI组件使用2
一、菜单:compontent
1. 选择菜单:OptonMenu
(1) OptonMenu在点击手机的menu键触发
(2) 显示OptonMenu的回调方法,在此方法中向menu中添加MenuItem
 Activity:onCreateOptionsMenu(Menu menu)
(3) 添加menuiten的两种方式:(1)纯编码方式:menu.add(…)
    (2)加载menu文件的方式
(4) 当选择某个菜单项的回调方法
 Activity:onOptionsItemSelected(MenuItem item)
2. 上下文菜单:ContextMenu
(1) 为某个视图添加创建ContextMenu的监听(需要长按触发)
View:setOnCreateContextMenuListener(Listener)
(2) 显示菜单的回调方法
  Activity:onCreateOptionsMenu(Menu,view,menulnfo)
(3) 当选择某个菜单的回调方法
  Activity:onContextItemSelected(MenuItem item)
3. 弹出菜单:PopMenu
(1) 用于某个组件上
 PopupMenu men=new PopupMenu(MainActivity,this,btn);
(2) 创建一个菜单选项文件
(3) 加载菜单文件
(4) 给弹出添加事件
(5) 显示弹出菜单
 Men.show();
二、进度条:Component
1. 圆形进度条:Progressbar
<Progressbar
 //指定ID
  android:id=”@+id/pd_test1_loading1”
//宽度
  android:layout_width=”wrap_contentt”
//高度
  android:layout_height=”wrap_content”
//水平进度条
  Style=“?android:attr/progressBarStyleHorizontal”
//当前进度
  android:progress=”   “
//最大进度
  android:max=”   “
2. 拖拽进度条:SeekBar
<SeekBar
//指定ID
  android:id=”@+id/seekBar”
//宽度
  android:layout_width=”match_parent”
//高度
  android:layout_height=”match_parent”
//当前进度
  android:progress=”   “
//最大进度
  android:max=”   “
3. 星级进度条:RatingBar
<RatingBar
//指定ID
  android:id=”@+id/seekBar”
//设置星的数量
  android:rating=”  “
//宽度
  android:layout_width=”match_parent”
//高度
  android:layout_height=”match_parent”
//设置每次星的数目
  android:rating=”  “

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值