Saturday 9 June 2012

Button in android

Button demo

  • Button in android mostly used to get action from user.
  • You can get action from button in onClick() event.
  • In android button works same as it works in java.
  • Two ways to create Button in android
    • Using xml file in layout

               <Button
              android:id="@+id/button1"
              android:layout_width="
      wrap_content"
              android:layout_height="wrap_content"
              android:text="My Button"/>

       
    • Using java code in activity class
             
               Button btnDynamic = new Button(this);
              btnDynamic.setText("Dynamically created Button");
  • Types of Button in android
    • Button
       
    • ToggleButton
      • <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="77dp"
        android:layout_height="wrap_content"
        android:text="ToggleButton" />
         
    • ImageButton
      • <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/gtumcaicon" >
         
    • CheckBox
      • <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Select" >
         
    • RadioButton
      • <RadioGroup
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
              <RadioButton
           android:id="@+id/red"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Red" />

           <RadioButton
           android:id="@+id/green"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Green" />
        </
        RadioGroup>

2 comments:

amandalee23 said...

you are kinda...amazing....another games and apps has been dated to launch soon..

android developer   

Unknown said...
This comment has been removed by a blog administrator.

Post a Comment

Fill free to post your Queries and Suggesion...!

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Review