1.RadioButton(单选按钮)
  嵌入到RsdioGroup中实现单选效果
  android:checkedButton="radio的id值"

  int getCheckedRadioButtonId(); //获得被选中的radionutton的id

  <RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checkedButton="@+id/rb2"
>
<RadioButton
android:id="@+id/rb1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="西瓜"
/>
<RadioButton
android:id="@+id/rb2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="苹果"
/>
</RadioGroup>

代码示例

2.ImageView(图片控件)
  android:src //图片的资源id
  android:maxWidth //最大宽度
  android:maxHeight //最大高度
  android:adjustViewBounds //设置为true,则maxWidth和maxHeigth生效

3.ImageButton(图片按钮)

     <ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxWidth="50px"
android:maxHeight="50px"
android:adjustViewBounds="true"
android:src="@drawable/a"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/p"
/>

代码示例

4.TimePicker(时间控件)
5.DatePicker(日期控件)
  //修改日期
  void updateDate(int year,int monthOfYear,int dayOfMonth)
  注意:monthOfYear是从0~11表示1-12月

 <TimePicker
android:id="@+id/tp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<DatePicker
android:id="@+id/dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

代码示例

6.Spinner
  6.1下拉列表项的配置方式
    a.资源文件配置
      第一步:在string.xml配置
        <string-array name="citys">
          <item>上海</item>
          <item>长沙</item>
          <item>益阳</item>
        </string-array>
      第二步:指定资源
      android:entries="@array/citys"
    b.适配器配置
      第一种:资源配置
        ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this, 资源id, 列表显示的样式);
      第二种:列表配置
        ArrayAdapter<CharSequence> adapte=new ArrayAdapter<CharSequence>(this,列表显示的样式,集合数据);

 <Spinner
android:id="@+id/sp1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/city"
android:entries="@array/citys"
/>
<Spinner
android:id="@+id/sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/city"
android:entries="@array/citys"
/> <string name="city">城市</string>
<string-array name="citys">
<item>上海</item>
<item>长沙</item>
<item>益阳</item>
</string-array>

代码示例

Android的方法和属性(2)的更多相关文章

  1. Android的方法和属性(1)

    1.Activity常用的方法 View findViewById(int id) //根据组件的ID取得组件对象 setContentView(int layoutResID) //设置布局文件,设 ...

  2. android中xml tools属性详解

    第一部分 安卓开发中,在写布局代码的时候,ide可以看到布局的预览效果. 但是有些效果则必须在运行之后才能看见,比如这种情况:TextView在xml中没有设置任何字符,而是在activity中设置了 ...

  3. android中xmlns:tools属性详解

    今天读到一篇总结的非常棒的文章,写的逻辑很清晰也很实用,很少见到如此棒的文章了.就原文转发过来,我把格式给整理了一下,分享给园子里的各位朋友!好久没写博客了,就为2015年的11月留份纪念吧.希望对你 ...

  4. 【Android】使用persist属性来调用脚本文件

    Android系统中有许多属性,属性由两个部分组成:name & value,可以使用这些属性来记录系统设置或进程之间的信息交换.Android系统在启动过程时会按序从以下几个文件中加载系统属 ...

  5. Android开发之EditText属性详解

    1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true" // 以”.”形式显示文本 ( ...

  6. android控件的属性

    android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...

  7. 【转】 Android开发之EditText属性详解

    原文网址:http://blog.csdn.net/qq435757399/article/details/7947862 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: ...

  8. Android中的windowSoftInputMode属性详解

    这篇文章主要介绍了Android中的windowSoftInputMode属性详解,本文对windowSoftInputMode的9个属性做了详细总结,需要的朋友可以参考下     在前面的一篇文章中 ...

  9. Android中Edittext的属性

    //此为转载别人的,挺不错的 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true"  ...

随机推荐

  1. 【算法题12 解码方法decode way】

    1.来源LeetCode91 一条包含字母 A-Z 的消息通过以下方式进行了编码: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 给定一个只包含数字的非空字符串,请 ...

  2. 解锁CHM文件

    刚在网上下载了CHM格式的文件,打开之后,右侧部分一片空白. 原因:可能是,系统针对来源不明文件的一种保存措施吧 解决方法: 1.选中文件,右键打开属性对话框,在 “常规”选项卡中 勾选 [解除锁定] ...

  3. 用VS2013编译FFMPEG232

    http://blog.csdn.net/finewind/article/details/38854517 如果只是拿来使用,网上有现成的SDK.但我是想深入研究FFMPEG代码,又不熟悉Linux ...

  4. Http请求的TCP连接

    我们一直认为,HTTP连接分为长连接和短连接,而我们现在常用的都是HTTP1.1,因此我们用的都是长连接. 这句话其实只对了一半,我们现如今的HTTP协议,大部分都是1.1的,因此我们平时用的基本上都 ...

  5. jQuery上下切换带缩略图的焦点图

    在线演示 本地下载

  6. jQuery带缩略图的宽屏焦点图插件

    在线演示 本地下载

  7. 20145219 《Java程序设计》第08周学习总结

    20145219 <Java程序设计>第08周学习总结 教材学习内容总结 通用API 日志API 1.java.util.logging包提供了日志功能相关类与接口,使用日志的起点是log ...

  8. 在Linux系统下使用Github的基本教程

    1. 安装git: sudo apt-get install git-core git-gui git-doc 2.到https://github.com/ 注册一个帐号,一会儿客户端登录的时候要使用 ...

  9. [BZOJ1721][Usaco2006 Mar]Ski Lift 缆车支柱

    Description Farmer Ron in Colorado is building a ski resort for his cows (though budget constraints ...

  10. Spring MVC执行原理和基于Java的配置过程

    一.Spring MVC执行原理和基于Java配置的配置过程 (一)Spring MVC执行过程,大致为7步. 所有的请求都会经过Spring的一个单例的DispacherServlet. Dispa ...