职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 813|回复: 11

android 控件使用集锦

  [复制链接]
能文能武 发表于 2011-7-27 09:15 | 显示全部楼层 |阅读模式
layout.xml
  1. <PRE class=java name="code">        <RadioGroup android:id="@+id/sex" style="@style/textInfo" android>   
  2.             <RadioButton android:text="男:" android:id="@+id/radionBtn_man" ></RadioButton>   
  3.             <RadioButton android:text="女:" android:id="@+id/radionBtn_woman" ></RadioButton>   
  4.         </RadioGroup></PRE>   
  5.    

  6.   <RadioGroup android:id="@+id/sex" style="@style/textInfo" android>       <RadioButton android:text="男:" android:id="@+id/radionBtn_man" ></RadioButton>       <RadioButton android:text="女:" android:id="@+id/radionBtn_woman" ></RadioButton>   </RadioGroup>                  <RadioGroup android:id="@+id/sex" style="@style/textInfo" android>
  7.                         <RadioButton android:text="男:" android:id="@+id/radionBtn_man" ></RadioButton>
  8.                         <RadioButton android:text="女:" android:id="@+id/radionBtn_woman" ></RadioButton>
  9.                 </RadioGroup>
  10.    
  11. <PRE class=java name="code">RadioButton rb = (RadioButton) findViewById(sexRadioGroup.getCheckedRadioButtonId());   
  12.             mUser.setSex(((RadioButton) findViewById(sexRadioGroup.getCheckedRadioButtonId())).getText().toString());</PRE>   
  13.    

  14.   RadioButton rb = (RadioButton) findViewById(sexRadioGroup.getCheckedRadioButtonId());               mUser.setSex(((RadioButton) findViewById(sexRadioGroup.getCheckedRadioButtonId())).getText().toString());  RadioButton rb = (RadioButton) findViewById(sexRadioGroup.getCheckedRadioButtonId());
  15.                         mUser.setSex(((RadioButton) findViewById(sexRadioGroup.getCheckedRadioButtonId())).getText().toString());
  16.   
复制代码
钰云 发表于 2011-7-27 09:15 | 显示全部楼层
<RadioGroup android:id="@+id/sex" style="@style/textInfo" androidrientation="horizontal">

<RadioGroup android:id="@+id/sex" style="@style/textInfo" androidrientation="vertical">

其中的androidrientation="vertical" 是设置group中的布局水平还是垂直,默认是垂直

月上萧萧 发表于 2011-7-27 09:15 | 显示全部楼层
<RadioButton android:text="男:" android:id="@+id/radionBtn_man" android:checked="true"></RadioButton>

android:checked="true" 标示默认选中

ps:如果多个radiobutton都有android:checked="true",则选中最后一个

愚人 发表于 2011-7-27 09:15 | 显示全部楼层
Android中TextVIew一些属性


android:layout_gravity="center_vertical"
设置控件显示的位置:默认top,这里居中显示,还有bottom
android:hint="请输入数字!"
设置显示在空间上的提示信息
android:numeric="integer"
设置只能输入整数,如果是小数则是:decimal
android:singleLine="true"
设置单行输入,一旦设置为true,则文字不会自动换行。
android:password="true"
设置只能输入密码
android:gravity="top"
EditText设置,这一行就可以让光标处于第一行了,若不设置默认就居中
TextView则在最顶上
android:textColor = "#ff8c00"
字体颜色
android:textStyle="bold"
字体,bold, italic, bolditalic
android:textSize="20dip"
大小
android:capitalize = "characters"
以大写字母写
android:textAlign="center"
EditText没有这个属性,但TextView有
android:autoText:自动拼写帮助
android:editable:是否可编辑
android:textColorHighlight="#cccccc"
被选中文字的底色,默认为蓝色
android:textColorHint="#ffff00"
设置提示信息文字的颜色,默认为灰色
android:textScaleX="1.5"
控制字与字之间的间距
android:typeface="monospace"
字型,normal, sans, serif, monospace
android:background="@null"
空间背景,这里没有,指透明,将EditText自定义的背景去掉
android:imeOptions="actionDone"
设置软键盘的Enter键
android:layout_weight="1"
权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。
android:textAppearance="?android:attr/textAppearanceLargeInverse"

fl 发表于 2011-7-27 09:15 | 显示全部楼层
android:singleLine="false"

换行

紫衿 发表于 2011-7-27 09:15 | 显示全部楼层
大神能帮我看下这个问题不?http://www.iteye.com/topic/1056435

叫我小乖 发表于 2011-7-27 09:15 | 显示全部楼层
地址不存在

走失的猫咪 发表于 2011-7-27 09:16 | 显示全部楼层
LZ最好弄个手册。这样来的话你会悲剧。

北大青鸟 发表于 2011-7-27 09:16 | 显示全部楼层
性别请表用sex了,有个词叫gender

 楼主| 能文能武 发表于 2011-7-27 09:16 | 显示全部楼层
写一篇帖子,总结,这样很零散.
翻译一下API做Demo,不是很好么


找不到我 发表于 2011-8-5 12:37 | 显示全部楼层
刚才我还看见了呢.
醉倚西风 发表于 2011-8-13 11:33 | 显示全部楼层
嘿嘿...没事我才不骂人呢...
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-5-1 00:24 , Processed in 0.142720 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表