SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Android Button 
BHAVIN JOSHI 
125010693017 
1
Index 
 About Button 
 XML File 
 Java File 
 Example 
2
XML File 
<Button 
android:id="@+id/button1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content” 
android:text=“radiobutton" /> 
<ImageButton 
android:id="@+id/img_button1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content” 
android:src=“@drawable/droid” 
/> 
3
About Button 
A Basic Button is often use to perform some sort of 
actions, such as submitting a selection. 
A basic Button control can contain a text or image label. 
Within the xml layout resources, button are specified 
using “<button>” element. 
The Primary attribute for basic button is the field. This is 
the label that appear on middle of button’s face. 
Example. We often use button control with text 
“ok”,”cancel” and “submit”. 
4
JAVA File 
5 
1. Create a class implements the interface 
button.setOnClickListener 
2. Implement onClickListener() method 
3. Perform the action on Button using the method void 
onClick(). 
within the onClick() method, you are free to carry out 
whatever action you need.
Example 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 
<ImageButton 
android:id="@+id/image_button" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content“ 
android:src=“@drawable/submit/” /> 
<Button 
android:id="@+id/button1“ 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/Cancel” /> 
</LinearLayout> 
6
Cont…. 
7
Java Code of Example 
package sl.mc; 
import android.os.Bundle; 
import android.app.Activity; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.ImageButton; 
import android.widget.Toast; 
public class MainActivity extends Activity { 
ImageButton button; 
Button button2; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_main); 
8
Cont… 
button=(ImageButton) findViewById(R.id.imageButton1); 
button2=(Button) findViewById(R.id.button1); 
button.setOnClickListener(new OnClickListener() { 
@Override 
public void onClick(View arg0) { 
// TODO Auto-generated method stub 
Toast.makeText(getApplicationContext(), "image button is click", 
Toast.LENGTH_LONG).show(); 
} 
}); 
9
Cont… 
button2.setOnClickListener(new OnClickListener() { 
@Override 
public void onClick(View arg0) { 
// TODO Auto-generated method stub 
Toast.makeText(getApplicationContext(), "Cancel Button is click", Toast.LENGTH_LONG).show(); 
} 
}); 
} 
10
Thank You 
11

Weitere ähnliche Inhalte

Was ist angesagt?

Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
alexjones89
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
Ahsanul Karim
 
android layouts
android layoutsandroid layouts
android layouts
Deepa Rani
 

Was ist angesagt? (20)

Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Introduction To Mobile Application Development
Introduction To Mobile Application DevelopmentIntroduction To Mobile Application Development
Introduction To Mobile Application Development
 
Introduction to mobile application
Introduction to mobile applicationIntroduction to mobile application
Introduction to mobile application
 
Android application development ppt
Android application development pptAndroid application development ppt
Android application development ppt
 
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
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Fragment
Fragment Fragment
Fragment
 
android layouts
android layoutsandroid layouts
android layouts
 
Understanding android security model
Understanding android security modelUnderstanding android security model
Understanding android security model
 
Android security
Android securityAndroid security
Android security
 
jQuery
jQueryjQuery
jQuery
 
Notification android
Notification androidNotification android
Notification android
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Objective c
Objective cObjective c
Objective c
 
Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Android ppt
Android pptAndroid ppt
Android ppt
 

Andere mochten auch

Advanced portfolio research and planning
Advanced portfolio   research and planningAdvanced portfolio   research and planning
Advanced portfolio research and planning
shanarochelle
 
Mobile sites + apps
Mobile sites + appsMobile sites + apps
Mobile sites + apps
YLLG
 
Be a Part of Our Success
Be a Part of Our SuccessBe a Part of Our Success
Be a Part of Our Success
osamuels1
 
Powerpoint unit 1 finished
Powerpoint unit 1 finishedPowerpoint unit 1 finished
Powerpoint unit 1 finished
Dayna Crawford
 
Recerca clínica en salut mental per Elisabet Vilella - Sessió de Residents 2...
Recerca clínica en salut mental per Elisabet Vilella -  Sessió de Residents 2...Recerca clínica en salut mental per Elisabet Vilella -  Sessió de Residents 2...
Recerca clínica en salut mental per Elisabet Vilella - Sessió de Residents 2...
Grup Pere Mata
 

Andere mochten auch (20)

Advanced portfolio research and planning
Advanced portfolio   research and planningAdvanced portfolio   research and planning
Advanced portfolio research and planning
 
Arizona Economic Housing Outlook
Arizona Economic Housing OutlookArizona Economic Housing Outlook
Arizona Economic Housing Outlook
 
Powerpoint unit 1
Powerpoint unit 1 Powerpoint unit 1
Powerpoint unit 1
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Superframe Scheduling with Beacon Enable Mode in Wireless Industrial Networks
Superframe Scheduling with Beacon Enable Mode in Wireless Industrial NetworksSuperframe Scheduling with Beacon Enable Mode in Wireless Industrial Networks
Superframe Scheduling with Beacon Enable Mode in Wireless Industrial Networks
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Remote Monitoring of Lead-Acid Battery Based on WLAN
Remote Monitoring of Lead-Acid Battery Based on WLANRemote Monitoring of Lead-Acid Battery Based on WLAN
Remote Monitoring of Lead-Acid Battery Based on WLAN
 
Bao gia may 2015 -- CONPEN COFFEE -- CTY TNHH TM XNK KIẾN NAM
Bao gia may 2015 -- CONPEN COFFEE  -- CTY TNHH TM XNK KIẾN NAMBao gia may 2015 -- CONPEN COFFEE  -- CTY TNHH TM XNK KIẾN NAM
Bao gia may 2015 -- CONPEN COFFEE -- CTY TNHH TM XNK KIẾN NAM
 
Mobile sites + apps
Mobile sites + appsMobile sites + apps
Mobile sites + apps
 
20150223_Infoday H2020_Espacio_Fernando Camacho
20150223_Infoday H2020_Espacio_Fernando Camacho20150223_Infoday H2020_Espacio_Fernando Camacho
20150223_Infoday H2020_Espacio_Fernando Camacho
 
Be a Part of Our Success
Be a Part of Our SuccessBe a Part of Our Success
Be a Part of Our Success
 
Powerpoint unit 1 finished
Powerpoint unit 1 finishedPowerpoint unit 1 finished
Powerpoint unit 1 finished
 
Network-based Wireless for Remote Monitoring Lead-Acid Battery
Network-based Wireless for Remote Monitoring Lead-Acid BatteryNetwork-based Wireless for Remote Monitoring Lead-Acid Battery
Network-based Wireless for Remote Monitoring Lead-Acid Battery
 
Evaluation #6
Evaluation #6Evaluation #6
Evaluation #6
 
Cd cover conventions analysis
Cd cover conventions analysisCd cover conventions analysis
Cd cover conventions analysis
 
Diseño de sistemas digitales con contadores
Diseño de sistemas digitales con contadoresDiseño de sistemas digitales con contadores
Diseño de sistemas digitales con contadores
 
06_CI4_SOLID SURFACE_Nora Lardiés
06_CI4_SOLID SURFACE_Nora Lardiés06_CI4_SOLID SURFACE_Nora Lardiés
06_CI4_SOLID SURFACE_Nora Lardiés
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Basında Bugün Göztepe
Basında Bugün GöztepeBasında Bugün Göztepe
Basında Bugün Göztepe
 
Recerca clínica en salut mental per Elisabet Vilella - Sessió de Residents 2...
Recerca clínica en salut mental per Elisabet Vilella -  Sessió de Residents 2...Recerca clínica en salut mental per Elisabet Vilella -  Sessió de Residents 2...
Recerca clínica en salut mental per Elisabet Vilella - Sessió de Residents 2...
 

Ähnlich wie Android Button

Ähnlich wie Android Button (20)

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
 
4.preference management
4.preference management 4.preference management
4.preference management
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgets
 
Android
AndroidAndroid
Android
 
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 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
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
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
 
06 UI Layout
06 UI Layout06 UI Layout
06 UI Layout
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
 
Android Application Fundamentals.
Android Application Fundamentals.Android Application Fundamentals.
Android Application Fundamentals.
 
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
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Layout
LayoutLayout
Layout
 
Android UI Reference
Android UI ReferenceAndroid UI Reference
Android UI Reference
 
android level 3
android level 3android level 3
android level 3
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Android Button

  • 1. Android Button BHAVIN JOSHI 125010693017 1
  • 2. Index  About Button  XML File  Java File  Example 2
  • 3. XML File <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content” android:text=“radiobutton" /> <ImageButton android:id="@+id/img_button1" android:layout_width="wrap_content" android:layout_height="wrap_content” android:src=“@drawable/droid” /> 3
  • 4. About Button A Basic Button is often use to perform some sort of actions, such as submitting a selection. A basic Button control can contain a text or image label. Within the xml layout resources, button are specified using “<button>” element. The Primary attribute for basic button is the field. This is the label that appear on middle of button’s face. Example. We often use button control with text “ok”,”cancel” and “submit”. 4
  • 5. JAVA File 5 1. Create a class implements the interface button.setOnClickListener 2. Implement onClickListener() method 3. Perform the action on Button using the method void onClick(). within the onClick() method, you are free to carry out whatever action you need.
  • 6. Example <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ImageButton android:id="@+id/image_button" android:layout_width="wrap_content" android:layout_height="wrap_content“ android:src=“@drawable/submit/” /> <Button android:id="@+id/button1“ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Cancel” /> </LinearLayout> 6
  • 8. Java Code of Example package sl.mc; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageButton; import android.widget.Toast; public class MainActivity extends Activity { ImageButton button; Button button2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 8
  • 9. Cont… button=(ImageButton) findViewById(R.id.imageButton1); button2=(Button) findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "image button is click", Toast.LENGTH_LONG).show(); } }); 9
  • 10. Cont… button2.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "Cancel Button is click", Toast.LENGTH_LONG).show(); } }); } 10