Android Learning notes-common controls

Source: Internet
Author: User

radio Button Radio

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/8F/wKioL1RrArjibAQOAAAeUve5e_A037.jpg "title=" Qq20141118162354.png "alt=" Wkiol1rrarjibaqoaaaeuve5e_a037.jpg "/>

        <RadioGroup              android:id= "@+id/gendergroup"              android:layout_width= "Wrap_content"              android:layout_height= "Wrap_content"              android:orientation= "Vertical" >             <RadioButton                  android:id= "@+id/femalebutton"                  android:layout_width= "Wrap_content"                  android:layout_height= "Wrap_ Content "                android:text= "@string/female"/>                          <RadioButton                  android:id= "@+id/malebutton"                  android:layout_width= "Wrap_content"                  android:layout_height= " Wrap_content "                 android:text= "@string/male"/>        </radiogroup>
Gendergroup = (radiogroup) Findviewbyid (r.id.gendergroup); Malebutton = (RadioButton) Findviewbyid (R.id.malebutton); Femalebutton = (RadioButton) Findviewbyid (R.id.femalebutton);//...gendergroup.setoncheckedchangelistener (new Radiogroup.oncheckedchangelistener () {@Overridepublic void oncheckedchanged (radiogroup group, int checkedid) {//TODO Auto-generated Method Stubif (femalebutton.getid () = = Checkedid) {System.out.println ("female"); Toast.maketext (Mainactivity.this, "female", Toast.length_short). Show (); else if (malebutton.getid () = = Checkedid) {System.out.println ("female"); Toast.maketext (Mainactivity.this, "male", Toast.length_short). Show ();}});

Multi-Select CheckBox

650 "this.width=650;" src= "http://s3.51cto.com/wyfs02/ M02/53/8f/wkiol1rraynyhoifaaau_yuhos4262.jpg "title=" Qq20141118162405.png "alt=" wkiol1rraynyhoifaaau_ Yuhos4262.jpg "/>

        <CheckBox              android:id= "@+id/swim"              android:layout_width= "Wrap_content"              android:layout_height= "Wrap_content"              android:layout_below= "@id/gendergroup"              android:text= "@string/swim"/>                 <CheckBox              android:id= "@+id/read"              android:layout_width= "Wrap_content"              android:layout_height= "WRap_content "            android:layout_below=" @id/ Swim "            android:text=" @string/read "/>                 <checkbox              android:id= "@+id/run"              android:layout_width= "Wrap_content"              android:layout_height= "Wrap_content"              android:layout_below= "@id/read"              android:text= "@string/run"/>
swimbox =  (checkbox)  findviewbyid (r.id.swim);runbox =  (checkbox)  findviewbyid ( R.id.run);readbox =  (CheckBox)  findviewbyid (r.id.read);//...swimbox.setoncheckedchangelistener ( New oncheckedchangelistener ()  {@Overridepublic  void oncheckedchanged (compoundbutton  buttonview,boolean ischecked)  {// TODO Auto-generated method stubif  ( isChecked)  {system.out.println ("swim is checked");}  else {system.out.println ("swim is unchecked");}}); Readbox.setoncheckedchangelistener (New oncheckedchangelistener ()  {@Overridepublic  void  OnCheckedChanged (compoundbutton buttonview,boolean ischecked)  {// todo auto-generated  method stubif  (isChecked)  {system.out.println ("read is checked");}  else {system.out.println ("read is unchecked");}}); Runbox.setoncheckedchangelistener (New onCheckedchangelistener ()  {@Overridepublic  void oncheckedchanged (Compoundbutton buttonview, boolean ischecked)  {// TODO Auto-generated method stubif  (isChecked)  { System.out.println ("run is checked");}  else {system.out.println ("run is unchecked");}});}

Progress bar ProgressBar

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/92/wKiom1RrC3CA0KiSAABOqEquBjw597.jpg "title=" Qq20141118170243.png "alt=" Wkiom1rrc3ca0kisaaboqequbjw597.jpg "/>

<progressbar     android:id= "@+id/firstBar"     style= "? Android:attr/progressbarstylehorizontal"     android:layout _width= "200DP"     android:layout_height= "Wrap_content"     android: Visibility= "Gone"/><progressbar     android:id= "@+id/secondbar"      style= "Android:attr/progressbarstyle"     android:layout_width= "200DP"      android:layout_height= "Wrap_content"     android:layout_below= "@id/ Firstbar "    android:visibility=" Gone "/><button android:id=" @+id/myButton "     android:layout_width= "wrap_content"     android:layout_height= "wrap _content "    android:layout_below=" @id/secondbar "    android:text=" start /> 
public class mainactivity extends actionbaractivity {private progressbar  firstbar = null;private progressbar secondbar = null;private button  mybuton = null;private int i = 0; @Overrideprotected  void oncreate ( bundle savedinstancestate)  {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main );firstbar =  (ProgressBar)  findviewbyid (R.id.firstbar);secondbar =  (ProgressBar)  findviewbyid (R.id.secondbar);mybuton =  (Button)  findviewbyid (R.id.mybutton); Mybuton.setonclicklistener (New buttonlistener ());} class buttonlistener implements onclicklistener{@Overridepublic  void onclick (View &NBSP;V)  {if  (i == 0)  {firstbar.setvisibility (view.visible); Secondbar.setvisibility ( view.visible);} else if  (I < firstbar.getmax ())  {//set the value of the Zhu progress bar FIRSTBAR.SEtprogress (i);//Set the value of the second progress bar secondbar.setsecondaryprogress (I&NBSP;+&NBSP;10);//The default progress bar does not show the status of// Secondbar.setprogress (i);} Else {firstbar.setvisibility (View.gone); secondbar.setvisibility (View.gone);} i = i + 10;}}}

List ListView

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/93/wKiom1RrKF_C8RvOAACtnsa1S0g551.jpg "title=" Qq20141118190642.png "alt=" Wkiom1rrkf_c8rvoaactnsa1s0g551.jpg "/>

Main.xml

<?xml version= "1.0"  encoding= "Utf-8"? ><linearlayout xmlns:android= "http// Schemas.android.com/apk/res/android "    android:layout_width=" Match_parent "     android:layout_height= "match_parent"     android:orientation= "vertical"   >        <LinearLayout          android:id= "@+id/listlinearlayout"         android:layout_ Width= "Fill_parent"         android:layout_height= "Wrap_content"          android:orientation= "Vertical" >                 <listview android:id= "@+id/android: List "            android:layout_width=" Fill_parent "            android:layout_height= "Wrap_content"              android:drawselectorontop= "false"              android:scrollbars= "Vertical"/>    </ Linearlayout></linearlayout>

user.xml

<?xml version= "1.0"  encoding= "Utf-8"? ><linearlayout xmlns:android= "http// Schemas.android.com/apk/res/android "    android:layout_width=" Match_parent "     android:layout_height= "match_parent"     android:orientation= "Horizontal"   >    <textview         android:id= "@+id /user_name "        android:layout_width=" 180dip "         android:layout_height= "30dip"          Android:textsize= "10pt"         android:singleline= "true"/>    <textview         android:id= "@+id/user_ip"          android:layout_width= "Fill_parent"          android:layout_height="Fill_parent"         android:textsize= "10pt"          android:gravity= "Right"/> </linearlayout>

maina Ctivity.java

public class mainactivity extends listactivity{@Overrideprotected  void oncreate ( bundle savedinstancestate)  {super.oncreate (savedinstancestate); Setcontentview (R.layout.main); arraylist


This article is from "Avatar" blog, please make sure to keep this source http://shamrock.blog.51cto.com/2079212/1579162

Android Learning notes-common controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.