Download this Blogger Template by Clicking Here!

Ad 468 X 60

Share

Widgets

Thursday, December 08, 2011

Widgets

Working with PickerView in Android :


# We have to create a "Registration Page"  and having background image and time/date picker list :

  • Create an xml file named as "registration.xml" and copy and paste below code to this xml file.
  • Pick an image file and copy this in res/drawable folder.(for background)
    // Source Code of  registration.xml :
     <?xml version="1.0" encoding="utf-8"?>
     <ScrollView 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:scrollbars="vertical"
                android:scrollbarFadeDuration="3000"
               android:scrollbarDefaultDelayBeforeFade="1000"
              android:scrollbarSize="80.5dp">
 
              <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:orientation="vertical"
                            android:background="@drawable/bgscr" >
                                       <TextView
                                                 android:layout_width="fill_parent"
                                                 android:layout_height="wrap_content"
                                                 android:text="Registration"
                                                 android:layout_gravity="fill_horizontal"
                                                 android:textColor="#0000FF"
                                                 android:textSize="25px"
                                                 android:layout_marginLeft="30dp" />
   
                                     <TextView
                                                android:layout_width="fill_parent"
                                                android:layout_height="wrap_content"
                                                android:text="User Name :"
                                                android:textColor="#FF0000"
                                                android:textSize="17px" />
   
                                       <EditText 
                                                  android:layout_width="fill_parent"
                                                  android:layout_height="wrap_content"
                                                  android:hint="Enter username"
                                                  android:cursorVisible="true"
                                                  android:singleLine="true"/>
   
                                  <TextView 
                                            android:layout_width="fill_parent"
                                            android:layout_height="wrap_content"
                                            android:text="Password :"
                                            android:textColor="#FF0000"
                                            android:textSize="17px" />

                               <EditText
                                            android:layout_width="fill_parent"
                                            android:layout_height="wrap_content"
                                            android:password="true"
                                           android:singleLine="true"
                                           android:hint="Enter your password" />

                              <TextView 
                                          android:layout_width="fill_parent"
                                          android:layout_height="wrap_content"
                                          android:text=" Confirm Password :"
                                          android:textColor="#FF0000"
                                          android:textSize="17px" />
 
                               <EditText
                                          android:layout_width="fill_parent"
                                          android:layout_height="wrap_content"
                                          android:password="true"
                                          android:singleLine="true"
                                          android:hint="Re-enter your password" />


                              <TextView
                                         android:layout_width="fill_parent"
                                         android:layout_height="wrap_content"
                                         android:text="Choose your gender : "
                                         android:textColor="#FF0000"
                                         android:textSize="17px"/>

                             <RadioGroup
                                          android:id="@+id/rdgp"
                                          android:layout_width="fill_parent"
                                          android:layout_height="wrap_content"
                                          android:orientation="vertical" >
 
                                  <RadioButton 
                                                      android:id="@+id/rdb1"
                                                      android:layout_width="fill_parent"
                                                      android:layout_height="wrap_content"
                                                      android:text="Male"
                                                      android:textColor="#000000"/>
                                       <RadioButton
                                                      android:id="@+id/rdb1"
                                                      android:layout_width="fill_parent"
                                                      android:layout_height="wrap_content"
                                                      android:text="Female"
                                                      android:textColor="#000000"/>
       
                               </RadioGroup>

                               <TextView
                                            android:layout_width="fill_parent"
                                            android:layout_height="wrap_content"
                                            android:text="Choose your cell : "
                                            android:textColor="#FF0000"
                                            android:textSize="17px"/>
 
                                <RadioGroup
                                            android:id="@+id/rdgp1"
                                            android:layout_width="fill_parent"
                                            android:layout_height="wrap_content"
                                            android:orientation="vertical" >
 
                                              <RadioButton 
                                                          android:id="@+id/rdb1"
                                                          android:layout_width="fill_parent"
                                                          android:layout_height="wrap_content"
                                                          android:text="Android"
                                                          android:textColor="#000000"/>
                                              <RadioButton 
                                                          android:id="@+id/rdb1"
                                                          android:layout_width="fill_parent"
                                                          android:layout_height="wrap_content"
                                                          android:text="iPhone"
                                                          android:textColor="#000000"/>
   
                                   </RadioGroup>

                                  <ToggleButton
                                                 android:id="@+id/tglbtn"
                                                 android:layout_width="fill_parent"
                                                 android:layout_height="wrap_content"
                                                 android:textOn="Married"
                                                 android:textOff="Unmarried" />

                                   <TextView 
                                                 android:layout_width="fill_parent"
                                                 android:layout_height="wrap_content"
                                                 android:text="Date Of Birth : "
                                                 android:textColor="#FF0000"
                                                 android:textSize="17px"/>

                                  < DatePicker 
                                                 android:layout_width="fill_parent"
                                                 android:layout_height="fill_parent"/>

                                    <TimePicker
                                                android:layout_width="fill_parent"
                                                android:layout_height="fill_parent"/>

                                     <Button 
                                                android:id="@+id/btnRegister"
                                                android:layout_width="fill_parent"
                                                android:layout_height="wrap_content"
                                                android:text="Register" />

                                     <Button
                                                android:id="@+id/btnCancel"
                                                android:layout_width="fill_parent"
                                                android:layout_height="wrap_content"
                                                android:text="Cancel" />
                    </LinearLayout>
              </ScrollView>




Output :
Registration Form in Android



After Scrolling registration Page



SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
Author: Mohammad
Mohammad is the founder of STC Network which offers Web Services and Online Business Solutions to clients around the globe. Read More →

0 comments: