SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Android.Widgets
        Tutorial 1 : Empowering Android Widgets




By: Mr.PrajyotMainkar
MS Software Systems( BITS-Pilani)
BE(Hons.) Computer Engineering , PMP( IIT Delhi)
                                                   S
TextView – The Andro-Label

     The simplest widget is the label, referred to in Android as a TextView .
              Typically, these are used like labels in Android UI

Create a new android project with following contents in main.xml and run this project
                                    on emulator


                  <?xml version="1.0" encoding="utf-8"?>
    <TextViewxmlns:android="http://schemas.android.com/apk/res/android"
                     android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
              android:text="This is sample demo of TextView"
                                     />
TextView – The Andro-Label

The following output is obtained when you run the code via emulator.
Images – Fleeting with images

Android has two widgets to help embed images in your activities: ImageViewand
                                ImageButton.
  As the names suggest, they are image-based analogues to TextView and
                             Button , respectively.

                 <?xml version="1.0" encoding="utf-8"?>
   <ImageViewxmlns:android="http://schemas.android.com/apk/res/android"
                         android:id="@+id/icon"
                    android:layout_width="fill_parent"
                   android:layout_height="fill_parent"
                    android:adjustViewBounds="true"
                     android:src="@drawable/logo"
                                    />
    Note that, android:src takes path of image from the drawable folder(@ is the
     reference), so drag „n drop /paste any logo.png image to drawable folder.
Images – Fleeting with images

 The following output is obtained when you run the code via emulator.
EditText– Learning EditText

EditText is a thin veneer over TextView that configures itself to be editable. In the java
file (Src folder) import the file “import android.widget.EditText;”. Find the xml code
                                           below


                     <?xml version="1.0" encoding="utf-8"?>
       <EditTextxmlns:android="http://schemas.android.com/apk/res/android"
                           android:id="@+id/editfield"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                            android:singleLine="false"
                                         />
EditText – Learning EditText

package com.EditTextDemo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class EditTextDemoActivity extends Activity {
  /** Called when the activity is first created. */
@Override
EditText E;
  public void onCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
E.setText("This is sample edit text demo");
  }
}
CheckBox– Lets *Check*

•isChecked(): Determines if the check box has been checked.
•setChecked(): Forces the check box into a checked or unchecked
•state.
•toggle(): Toggles the check box as if the user checked it.



                   <?xml version="1.0" encoding="utf-8"?>
      <CheckBoxxmlns:android="http://schemas.android.com/apk/res/android"
                         android:id="@+id/checkbox"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                android:text="This checkbox is unchecked" />
CheckBox – Lets *Check*
package com.CheckBoxDemo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;

public class CheckBoxDemoActivity extends Activity implements CompoundButton.OnCheckedChangeListener {
CheckBox checkbox;
public void onCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
      checkbox=(CheckBox)findViewById(R.id.checkbox);
checkbox.setOnCheckedChangeListener(this);
      }
public void onCheckedChanged(CompoundButtonbuttonView,
booleanisChecked) {
if (isChecked) {
checkbox.setText("This checkbox is: checked");
}
else     {
checkbox.setText("This checkbox is: unchecked");
          }
      }
      }
CheckBox – Lets *Check*

The following output is obtained when you run the code via emulator.
RadioButton – Tune Up

                 •check(): Checks a specific radio button via its ID
      •clearCheck(): Clears all radio buttons, so none in the group are checked.
•getCheckedRadioButtonId(): Gets the ID of the currently checked radio button (or -1 if
                                  none are checked).

       Most times RadioButton widgets are placed inside a RadioGroup . The
 RadioGroup indicates a set of radio buttons whose state is tied, meaning only one
                                      button
   in that group can be selected at any time. If you assign an android:id to your
RadioGroup in your XML layout, you can access the group from your Java code and
RadioButton – Tune Up

•The XML Code is below. Make no changes to Java File :
        <?xml version="1.0" encoding="utf-8"?>
        <RadioGroup
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <RadioButton android:id="@+id/radio1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Goa" />
        <RadioButton android:id="@+id/radio2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Maharashtra" />
        <RadioButton android:id="@+id/radio3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Kerala" />
        </RadioGroup>
Thank you..
GET IN TOUCH– Tune Up
   RadioButton
                               Phone:
                               +91-9822987513
 facebook.com/prajyotmainkar

                               Email:
 twitter.com/prajyotm          prajyotm@msn.com

Weitere ähnliche Inhalte

Was ist angesagt?

Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
Richard Hyndman
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
Ahsanul Karim
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
Ahsanul Karim
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
Krazy Koder
 
View groups containers
View groups containersView groups containers
View groups containers
Mani Selvaraj
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
Ahsanul Karim
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 

Was ist angesagt? (20)

Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
 
Android UI
Android UIAndroid UI
Android UI
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
Day 15: Working in Background
Day 15: Working in BackgroundDay 15: Working in Background
Day 15: Working in Background
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
Create an android app for database creation using.pptx
Create an android app for database creation using.pptxCreate an android app for database creation using.pptx
Create an android app for database creation using.pptx
 
View groups containers
View groups containersView groups containers
View groups containers
 
List Views
List ViewsList Views
List Views
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android session 3
Android session 3Android session 3
Android session 3
 
Android session 2
Android session 2Android session 2
Android session 2
 
Develop a native application that uses GPS location.pptx
Develop a native application that uses GPS location.pptxDevelop a native application that uses GPS location.pptx
Develop a native application that uses GPS location.pptx
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 

Andere mochten auch

Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]
Nehil Jain
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Android GPS Tutorial
Android GPS TutorialAndroid GPS Tutorial
Android GPS Tutorial
Ahsanul Karim
 
Ateliers : Developpement mobile vs open source
Ateliers : Developpement mobile vs open sourceAteliers : Developpement mobile vs open source
Ateliers : Developpement mobile vs open source
Korteby Farouk
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial ppt
Rehna Renu
 

Andere mochten auch (20)

Android adapters
Android adaptersAndroid adapters
Android adapters
 
Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]Lecture Slides for List Views [Android ]
Lecture Slides for List Views [Android ]
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Java pour android
Java pour androidJava pour android
Java pour android
 
Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2Android Workshop Day 1 Part 2
Android Workshop Day 1 Part 2
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)
 
Android development - ListView & Adapter
Android development - ListView & AdapterAndroid development - ListView & Adapter
Android development - ListView & Adapter
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
Intent in android
Intent in androidIntent in android
Intent in android
 
Basic android-ppt
Basic android-pptBasic android-ppt
Basic android-ppt
 
Screen orientations in android
Screen orientations in androidScreen orientations in android
Screen orientations in android
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Day 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location APIDay 9: Make Your App Location Aware using Location API
Day 9: Make Your App Location Aware using Location API
 
ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
Android GPS Tutorial
Android GPS TutorialAndroid GPS Tutorial
Android GPS Tutorial
 
Ateliers : Developpement mobile vs open source
Ateliers : Developpement mobile vs open sourceAteliers : Developpement mobile vs open source
Ateliers : Developpement mobile vs open source
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial ppt
 
Day 3 of C++ Boot Camp - C++11 Language Deep Dive
Day 3 of C++ Boot Camp - C++11 Language Deep DiveDay 3 of C++ Boot Camp - C++11 Language Deep Dive
Day 3 of C++ Boot Camp - C++11 Language Deep Dive
 

Ähnlich wie Android Tutorials : Basic widgets

android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramio
slesulvy
 

Ähnlich wie Android Tutorials : Basic widgets (20)

Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample Project
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1
 
android level 3
android level 3android level 3
android level 3
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android
AndroidAndroid
Android
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Android Button
Android ButtonAndroid Button
Android Button
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
android training_material ravy ramio
android training_material ravy ramioandroid training_material ravy ramio
android training_material ravy ramio
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Creation of simple application using - step by step
Creation of simple application using - step by stepCreation of simple application using - step by step
Creation of simple application using - step by step
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
1. shared pref
1. shared pref1. shared pref
1. shared pref
 
06. Android Basic Widget and Container
06. Android Basic Widget and Container06. Android Basic Widget and Container
06. Android Basic Widget and Container
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 

Mehr von Prajyot Mainkar

Steps to install android
Steps to install androidSteps to install android
Steps to install android
Prajyot Mainkar
 

Mehr von Prajyot Mainkar (14)

Kolkata kreate - Talk by Prajyot Mainkar
Kolkata kreate - Talk by Prajyot MainkarKolkata kreate - Talk by Prajyot Mainkar
Kolkata kreate - Talk by Prajyot Mainkar
 
Devfest baroda 2019 By prajyot mainkar
Devfest baroda 2019 By prajyot mainkarDevfest baroda 2019 By prajyot mainkar
Devfest baroda 2019 By prajyot mainkar
 
Building for next india
Building for next indiaBuilding for next india
Building for next india
 
Pitch that matters
Pitch that mattersPitch that matters
Pitch that matters
 
Android Power Optimization: May the Power be with you
Android Power Optimization: May the Power be with youAndroid Power Optimization: May the Power be with you
Android Power Optimization: May the Power be with you
 
Android performance
Android performanceAndroid performance
Android performance
 
Gaining the app visibility that matters
Gaining the app visibility that mattersGaining the app visibility that matters
Gaining the app visibility that matters
 
DroidSync 2014
DroidSync 2014DroidSync 2014
DroidSync 2014
 
Nitrodroid 2013 - Closing Report
Nitrodroid 2013 - Closing ReportNitrodroid 2013 - Closing Report
Nitrodroid 2013 - Closing Report
 
Google Cloud Messaging
Google Cloud Messaging Google Cloud Messaging
Google Cloud Messaging
 
Building Hybrid Applications using PhoneGap
Building Hybrid Applications using PhoneGapBuilding Hybrid Applications using PhoneGap
Building Hybrid Applications using PhoneGap
 
Android Cloud to Device Messaging Framework
Android Cloud to Device Messaging FrameworkAndroid Cloud to Device Messaging Framework
Android Cloud to Device Messaging Framework
 
Evolution google-android play
Evolution google-android playEvolution google-android play
Evolution google-android play
 
Steps to install android
Steps to install androidSteps to install android
Steps to install android
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Android Tutorials : Basic widgets

  • 1. Android.Widgets Tutorial 1 : Empowering Android Widgets By: Mr.PrajyotMainkar MS Software Systems( BITS-Pilani) BE(Hons.) Computer Engineering , PMP( IIT Delhi) S
  • 2. TextView – The Andro-Label The simplest widget is the label, referred to in Android as a TextView . Typically, these are used like labels in Android UI Create a new android project with following contents in main.xml and run this project on emulator <?xml version="1.0" encoding="utf-8"?> <TextViewxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is sample demo of TextView" />
  • 3. TextView – The Andro-Label The following output is obtained when you run the code via emulator.
  • 4. Images – Fleeting with images Android has two widgets to help embed images in your activities: ImageViewand ImageButton. As the names suggest, they are image-based analogues to TextView and Button , respectively. <?xml version="1.0" encoding="utf-8"?> <ImageViewxmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/icon" android:layout_width="fill_parent" android:layout_height="fill_parent" android:adjustViewBounds="true" android:src="@drawable/logo" /> Note that, android:src takes path of image from the drawable folder(@ is the reference), so drag „n drop /paste any logo.png image to drawable folder.
  • 5. Images – Fleeting with images The following output is obtained when you run the code via emulator.
  • 6. EditText– Learning EditText EditText is a thin veneer over TextView that configures itself to be editable. In the java file (Src folder) import the file “import android.widget.EditText;”. Find the xml code below <?xml version="1.0" encoding="utf-8"?> <EditTextxmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/editfield" android:layout_width="fill_parent" android:layout_height="fill_parent" android:singleLine="false" />
  • 7. EditText – Learning EditText package com.EditTextDemo; import android.app.Activity; import android.os.Bundle; import android.widget.EditText; public class EditTextDemoActivity extends Activity { /** Called when the activity is first created. */ @Override EditText E; public void onCreate(BundlesavedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); E.setText("This is sample edit text demo"); } }
  • 8. CheckBox– Lets *Check* •isChecked(): Determines if the check box has been checked. •setChecked(): Forces the check box into a checked or unchecked •state. •toggle(): Toggles the check box as if the user checked it. <?xml version="1.0" encoding="utf-8"?> <CheckBoxxmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This checkbox is unchecked" />
  • 9. CheckBox – Lets *Check* package com.CheckBoxDemo; import android.app.Activity; import android.os.Bundle; import android.widget.CheckBox; import android.widget.CompoundButton; public class CheckBoxDemoActivity extends Activity implements CompoundButton.OnCheckedChangeListener { CheckBox checkbox; public void onCreate(BundlesavedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); checkbox=(CheckBox)findViewById(R.id.checkbox); checkbox.setOnCheckedChangeListener(this); } public void onCheckedChanged(CompoundButtonbuttonView, booleanisChecked) { if (isChecked) { checkbox.setText("This checkbox is: checked"); } else { checkbox.setText("This checkbox is: unchecked"); } } }
  • 10. CheckBox – Lets *Check* The following output is obtained when you run the code via emulator.
  • 11. RadioButton – Tune Up •check(): Checks a specific radio button via its ID •clearCheck(): Clears all radio buttons, so none in the group are checked. •getCheckedRadioButtonId(): Gets the ID of the currently checked radio button (or -1 if none are checked). Most times RadioButton widgets are placed inside a RadioGroup . The RadioGroup indicates a set of radio buttons whose state is tied, meaning only one button in that group can be selected at any time. If you assign an android:id to your RadioGroup in your XML layout, you can access the group from your Java code and
  • 12. RadioButton – Tune Up •The XML Code is below. Make no changes to Java File : <?xml version="1.0" encoding="utf-8"?> <RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Goa" /> <RadioButton android:id="@+id/radio2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Maharashtra" /> <RadioButton android:id="@+id/radio3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Kerala" /> </RadioGroup>
  • 13. Thank you.. GET IN TOUCH– Tune Up RadioButton Phone: +91-9822987513 facebook.com/prajyotmainkar Email: twitter.com/prajyotm prajyotm@msn.com