免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2781 | 回复: 3
打印 上一主题 下一主题

android控件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-17 10:44 |只看该作者 |倒序浏览
android控件




button




Java代码
  1. 1.<Button   
  2. 2.        android:id="@+id/button"  
  3. 3.        android:layout_width="wrap_content"  
  4. 4.        android:layout_height="wrap_content"  
  5. 5.        android:text="普通按钮"  
  6. 6.    >   
  7. 7.    </Button>   
  8. 8.    <ImageButton   
  9. 9.        android:id="@+id/imageButton"  
  10. 10.        android:layout_width="wrap_content"  
  11. 11.        android:layout_height="wrap_content"  
  12. 12.        android:src="@drawable/img"  
  13. 13.    >   
  14. 14.    </ImageButton>   
  15. 15.    <ToggleButton   
  16. 16.        android:id="@+id/toggleButton"  
  17. 17.        android:layout_width="wrap_content"  
  18. 18.        android:layout_height="wrap_content"  
  19. 19.    >   
  20. 20.    </ToggleButton>  
  21. <Button
  22.                 android:id="@+id/button"
  23.                 android:layout_width="wrap_content"
  24.                 android:layout_height="wrap_content"
  25.                 android:text="普通按钮"
  26.         >
  27.         </Button>
  28.         <ImageButton
  29.                 android:id="@+id/imageButton"
  30.                 android:layout_width="wrap_content"
  31.                 android:layout_height="wrap_content"
  32.                 android:src="@drawable/img"
  33.         >
  34.         </ImageButton>
  35.         <ToggleButton
  36.                 android:id="@+id/toggleButton"
  37.                 android:layout_width="wrap_content"
  38.                 android:layout_height="wrap_content"
  39.         >
  40.         </ToggleButton>
复制代码
监听事件

Java代码
  1. 1.public void onClick(View v) {//重写的事件处理回调方法   
  2. 2.        if(v == button){//点击的是普通按钮   
  3. 3.            textView.setText("您点击的是普通按钮");   
  4. 4.        }   
  5. 5.        else if(v == imageButton){//点击的是图片按钮   
  6. 6.            textView.setText("您点击的是图片按钮");   
  7. 7.        }   
  8. 8.        else if(v == toggleButton){//点击的是开关按钮   
  9. 9.            textView.setText("您点击的是开关按钮");   
  10. 10.        }         
  11. 11.    }  
复制代码

论坛徽章:
0
2
发表于 2014-07-01 16:55
不错的控件教程,感谢分享

论坛徽章:
0
3
发表于 2014-07-08 17:13
真心赞的控件知识分享

论坛徽章:
5
丑牛
日期:2014-01-21 08:26:26卯兔
日期:2014-03-11 06:37:43天秤座
日期:2014-03-25 08:52:52寅虎
日期:2014-04-19 11:39:48午马
日期:2014-08-06 03:56:58
4 [报告]
发表于 2014-07-18 17:29 |只看该作者
总体来说,速度不错,也比较稳定
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP