菜鸟Android学习01

如何获得文本框 单选框 多选框的值

> 程序代码分别如下所示
@获得文本框的值private EditText emailEdit ;    '''在onCreate方法中通过ID获得控键对象'''    emailEdit = (EditText)findViewById(R.id.emailEdit);    '''使用getText()方法得到控键的值'''    str = emailEdit.getText()+"";
@获得单选框的的值'''1-在.xml布局文件中使用RadioGroup控键生成单选框 程序代码如下所示 '''"@+id/sexRadioButton"         android:layout_width="wrap_content"         android:layout_height="wrap_content"        android:layout_weight="4"        android:orientation="horizontal"        >"@+id/radioButton1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"              **android:checked="true"**             android:text="@string/sex01"              />          "@+id/radioButton2"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="@string/sex02"              />    '''2-在.xml布局文件中使用RadioGroup控键生成单选框 程序代码如下所示 ''''''声明一个RadioGroup对象和一个 RadioButton对象'''    private RadioGroup  sexRadioGroup ;    private RadioButton  radioButton ; radioButton =(RadioButton)findViewById(sexRadioGroup.getCheckedRadioButtonId());       str = radioButton.getText()+"";
@获得多选框的的值'''1-在.xml布局文件中使用CheckBox控键生成多选框  '''"@+id/CheckBox01"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="@string/city01" />        "@+id/CheckBox02"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="@string/city02" />        "@+id/CheckBox03"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="1"            android:text="@string/city03" />'''在.java 文件中声明一个RadioGroup对象和一个 RadioButton对象'''    private CheckBox  cb ;'''获得多选框的值'''       int [] arr = new int[] {R.id.CheckBox01,R.id.CheckBox02,R.id.CheckBox03};       for(int i = 0 ;iif(cb.isChecked()){              str+= cb.getText()+"";          }       }

更多相关文章

  1. android按键映射
  2. Android游戏开发菜鸟之路(三)
  3. android rom修改小白有福了
  4. monkeyrunner在Android(安卓)SDK 4.0中无法运行的解决办法
  5. Ionic 程序打包发布Android版本
  6. file(内部存储与外部存储)
  7. android 环境配置和安装, Android系统包说明,基本控件,常用代码,
  8. PhoneGap开发Android
  9. Android(安卓)studio登录界面

随机推荐

  1. Android视图绘制流程完全解析(一)
  2. Android入门及环境搭建
  3. Android研究院之游戏开发帧动画(三)
  4. Android作业:一个3D相册源码
  5. 吃完果冻豆再来点啥?下一版Android命名酸
  6. Android内存管理机制
  7. Android新手轻松入门十问十答
  8. 刚进入Android终端即可使用busybox的命令
  9. JAVA和Android之较量
  10. 想抢先体验Android操作系统的魅力吗?那就