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>

Friday 8 June 2012

EditText in android

EditText in android



  • EditText in android is works as Text field.
  • You can get the data from the user.
  • Android gives facility to enter different type of data as per the requirement.
  • Two ways to create EditText in android
    • Using xml file in layout

               <EditText
              android:id="@+id/hello"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:hint="this is hint" />
       
    • Using java code in activity class
             
               EditText tvDynamic = new EditText (this);
              tvDynamic.setText("---> Dynamically created EditText ");
  • Types of EditText in android
    • Simple EditText
       
    • Password EditText
      • android:inputType="textPassword"
         
    • Number EditText
      •  android:inputType="number"
    • Password EditText
      •  android:inputType="textPassword"
    • Email EditText
      •  android:inputType="textEmailAddress"

    • MultiLine EditText
      •  android:inputType="textMultiLine"
         
    • Number EditText
      •  android:inputType="phone"
         
    • Time EditText
      •  android:inputType="time"
         
    • Date EditText
      •  android:inputType="date"
         
    • Number Signed EditText
      •  android:inputType="numberSigned"

Related links :

Thursday 7 June 2012

TextView in android

TextView in android.

 

  • TextView in android are works as label. 
  • It enables user to display text on the screen.
  • Generally text display in textview are static but user can set text dynamically.
  • Two ways to create text view in android
    • Using xml file in layout

               <TextView
              android:id="@+id/hello"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="@string/hello" />
       
    • Using java code in activity class
             
               TextView tvDynamic = new TextView(this);
              tvDynamic.setText("---> Dynamically created TextView");
       
  • Types of TextView in android
    • Large TextView
      • android:textAppearance="?android:attr/textAppearanceLarge"
         
    • Medium TextView
      • android:textAppearance="?android:attr/textAppearanceMedium"
         
    • Small TextView
      • android:textAppearance="?android:attr/textAppearanceSmall"
         
    • Checked TextView
             
            <CheckedTextView

            android:id="@+id/checkedTextView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CheckedTextView"/>
           

Wednesday 6 June 2012

How to install android (Step by step android installation)

Step-by-step process of android installation.
How to install android in windows 7? step by step installation of android in windows. simple way to install android. How to install android in PC? how to install android in laptop ? how to install android in eclipse? how to configure eclipse in android ? how to install android plug-ins in eclipse. How to download and install android in windows. Steps to install android,
  1. First of all download following things
  2. Install JDK
    • Set java class path
      RightClick on My Computer --> Properties --> Advance System setting --> Environment variable --> In System Variable Edit path variable --> put your directory path of JDK installation directory here up to bin folder
      Note: Don't  delete old values of path variable. Just add your dir path.

      for example: C:\Program Files\Java\jdk1.6.0_24\bin;
  3. Extract all zip files
    • Create folder in d:\android
    • Extract android-sdk-windows.zip in d:\android folder
    • Extract eclipse.zip in d:\android folder
    • Create one folder d:\android\myworkspace
    • Now you have structure like this
      • d:\android\
        • android-sdk-windows
        • eclipse
        • myworkspace
  4. Configure eclipse for android
    • Install ADT plug-ins in eclipse
    Go to d:\android\eclipse --> double click on eclipse.exe
    --> Click on Help menu --> Install new software --> 
    Click on Add button --> click on Archive button --> Select file ADT 17.zip --> Mark all checkboxs --> Click on next button --> Select I accept all --> Click on next button --> Finish
    •  Setting android SDK path
      Go to Windows menu --> select preference --> click on Android
      (in left side list) --> set SDK path (in our case d:\android\android-sdk-windows) --> click Apply --> Click Ok button
  5. Create new android project
Go to File menu --> new --> other --> Android Project --> Give Project name --> Select android version (for example Android 2.2) --> Click Next button --> give package name (for example com.gtumca.myname) --> Click on Finish

Related links :

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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