SlideShare une entreprise Scribd logo
1  sur  17
Android.Widgets
       Tutorial 2 : Powering with Selection Widget




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

Spinner is a widget similar to a drop down list selecting items. Here is the xml file
        <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <TextView
        android:id="@+id/selection"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />
        <Spinner android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        />
        </LinearLayout>
Spinner– The resource pool

                             Java File will contain following code
package com.spinner;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;

public class SpinnerActivity extends Activity implements
AdapterView.OnItemSelectedListener {
TextView selection;
String[] items={"Prajyot", "Prakash", "Mainkar"};

//Continued on next slide
Spinner– The resource pool

public void onCreate(BundlesavedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.main);
     selection=(TextView)findViewById(R.id.selection);
     Spinner spin=(Spinner)findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter<String>aAdapter=new
ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,
     items);
aAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aAdapter);
     }
public void onItemSelected(AdapterView<?> parent,
     View v, int position, long id) {
selection.setText(items[position]);
     }
public void onNothingSelected(AdapterView<?> parent) {
selection.setText("");
     }
     }
Spinner– The resource pool

The following output is obtained when you run the code via emulator.
Spinner– The resource pool

The following output is obtained when you run the code via emulator. The radio button
                           can be replaced by checkboxes.
GridView – Roar Louder

GridView is a ViewGroup that displays items in a 2-D,scrollable grid. The grid items
            get inserted automatically to the layout using a ListAdapter

         <?xml version="1.0" encoding="utf-8"?>
         <LinearLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         >
         <TextView
         android:id="@+id/selection"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         />
GridView– Roar Louder

               ..Continued from previous slide.


<GridView
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:verticalSpacing="40px"
android:horizontalSpacing="10px"
android:numColumns="auto_fit"
android:columnWidth="100px"
android:stretchMode="columnWidth"
android:gravity="center"
/>
</LinearLayout>
GridView– Roar Louder

                             Java File will contain following code
package com.Grid;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;

public class GridActivity extends Activity implements AdapterView.OnItemSelectedListener {
TextView selection;
     String[] items={"Goa", "Maharashtra", "TamilNadu", "Rajasthan", "Gujrat",
     "MP", "Karnataka", "Kerala", "Delhi", "AndraPradesh",
     "Assam", "Manipur", "Orissa", "Punjab", "J&K",
     "Himachal Pradesh", "West Bengal", "Tripura", "Uttarakhand", "Sikkim",
     "Bihar", "ArunachalP", "Chhattisgarh", "D&D", "Pondicherry"};
GridView– Roar Louder

 public void onCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);selection=(TextView)findViewById(R.id.selection);
GridViewg=(GridView) findViewById(R.id.grid);
g.setAdapter(newFunnyLookingAdapter(this,
     android.R.layout.simple_list_item_1,items));
g.setOnItemSelectedListener(this);
     }
     public void onItemSelected(AdapterView<?> parent, View v,
int position, long id) {
selection.setText(items[position]);
     }
     public void onNothingSelected(AdapterView<?> parent) {
selection.setText("");
}
GridView– Roar Louder

 private class FunnyLookingAdapter extends ArrayAdapter {
     Context ctxt;
FunnyLookingAdapter(Contextctxt, int resource,
     String[] items) {
super(ctxt, resource, items);
this.ctxt=ctxt;
     }
     public View getView(int position, View convertView,
ViewGroup parent) {
TextView label=(TextView)convertView;
     if (convertView==null) {
convertView=new TextView(ctxt);
     label=(TextView)convertView;
     }
label.setText(items[position]);
return(convertView);
     }
     }
     }
GridView – Roar Louder

The following output is obtained when you run the code via emulator.
AutoComplete – Intelligence
                  way
 Allows to suggest the remaining text-type using the intelligent way .Suggestions are
received from a collection of strings associated with the widget through ArrayAdapter
           <?xml version="1.0" encoding="utf-8"?>
           <LinearLayout
           xmlns:android="http://schemas.android.com/apk/res/android"
           android:orientation="vertical"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:padding="5dp"
           >
           <TextView
           android:id="@+id/selection"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:text="States"
           />
           <AutoCompleteTextViewandroid:id="@+id/edit"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:completionThreshold="3"/>
           </LinearLayout>
AutoComplete – Intelligence
                    way
                             Java File will contain following code
package com.AutoComplete;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;

public class AutoCompleteActivity extends Activity implements TextWatcher {
TextView selection;
AutoCompleteTextView edit;
String[] items={"Goa", "Maharashtra", "TamilNadu", "Rajasthan", "Gujrat",
"MP", "Karnataka", "Kerala", "Delhi", "AndraPradesh",
"Assam", "Manipur", "Orissa", "Punjab", "J&K",
"Himachal Pradesh", "West Bengal", "Tripura", "Uttarakhand", "Sikkim",
"Bihar", "ArunachalP", "Chhattisgarh", "D&D", "Pondicherry"};
AutoComplete – Intelligence
                    way
public void onCreate(BundlesavedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.main);
      selection=(TextView)findViewById(R.id.selection);
      edit=(AutoCompleteTextView)findViewById(R.id.edit);
edit.addTextChangedListener(this);
edit.setAdapter(newArrayAdapter<String>(this,
      android.R.layout.simple_dropdown_item_1line,
      items));
      }
public void onTextChanged(CharSequences, int start, int before,
int count) {
selection.setText(edit.getText());
      }
public void beforeTextChanged(CharSequences, int start,
int count, int after) {
      // used in case if interface
      }
public void afterTextChanged(Editables) {
      // used in case if interface
      }
      }
AutoComplete – Intelligence
           way

The following output is obtained when you run the code via emulator.
Thank you..
GET IN TOUCH– Tune Up
   RadioButton
                               Phone:
                               +91-9822987513
 facebook.com/prajyotmainkar

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

Contenu connexe

Tendances

Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & LayoutsVijay Rastogi
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfacesC.o. Nieto
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversCodeAndroid
 
android level 3
android level 3android level 3
android level 3DevMix
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cyclemssaman
 
Write an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptxWrite an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptxvishal choudhary
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Android Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxAndroid Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxvishal choudhary
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminarJoemarie Amparo
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - AndroidWingston
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon Berlin
 
Android Fundamental
Android FundamentalAndroid Fundamental
Android FundamentalArif Huda
 

Tendances (20)

Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & Layouts
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
Android Layout.pptx
Android Layout.pptxAndroid Layout.pptx
Android Layout.pptx
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
android level 3
android level 3android level 3
android level 3
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 
Android Programming.pptx
Android Programming.pptxAndroid Programming.pptx
Android Programming.pptx
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
 
Write an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptxWrite an application that draws basic graphical primitives.pptx
Write an application that draws basic graphical primitives.pptx
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
F1
F1F1
F1
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Android Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptxAndroid Application that makes use of RSS Feed.pptx
Android Application that makes use of RSS Feed.pptx
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminar
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
Droidcon2013 pro guard, optimizer and obfuscator in the android sdk_eric lafo...
 
Android Fundamental
Android FundamentalAndroid Fundamental
Android Fundamental
 
Android Button
Android ButtonAndroid Button
Android Button
 

Similaire à Android Tutorials - Powering with Selection Widget

Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
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 widgetsSiva Kumar reddy Vasipally
 
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...Inhacking
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in androidInnovationM
 
06. Android Basic Widget and Container
06. Android Basic Widget and Container06. Android Basic Widget and Container
06. Android Basic Widget and ContainerOum Saokosal
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android ProgrammingRaveendra R
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?Brenda Cook
 
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 ProjectJoemarie Amparo
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Mario Jorge Pereira
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...Ted Chien
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談awonwon
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDJordan Open Source Association
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesMichael Galpin
 

Similaire à Android Tutorials - Powering with Selection Widget (20)

List view2
List view2List view2
List view2
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
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
 
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
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 Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
Fragments: Why, How, What For?
Fragments: Why, How, What For?Fragments: Why, How, What For?
Fragments: Why, How, What For?
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
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
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015
 
Chapter 5 - Layouts
Chapter 5 - LayoutsChapter 5 - Layouts
Chapter 5 - Layouts
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 
1. shared pref
1. shared pref1. shared pref
1. shared pref
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
 
Android Materials Design
Android Materials Design Android Materials Design
Android Materials Design
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
Android
AndroidAndroid
Android
 

Plus de Prajyot Mainkar

Kolkata kreate - Talk by Prajyot Mainkar
Kolkata kreate - Talk by Prajyot MainkarKolkata kreate - Talk by Prajyot Mainkar
Kolkata kreate - Talk by Prajyot MainkarPrajyot Mainkar
 
Devfest baroda 2019 By prajyot mainkar
Devfest baroda 2019 By prajyot mainkarDevfest baroda 2019 By prajyot mainkar
Devfest baroda 2019 By prajyot mainkarPrajyot Mainkar
 
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 youPrajyot Mainkar
 
Gaining the app visibility that matters
Gaining the app visibility that mattersGaining the app visibility that matters
Gaining the app visibility that mattersPrajyot Mainkar
 
Nitrodroid 2013 - Closing Report
Nitrodroid 2013 - Closing ReportNitrodroid 2013 - Closing Report
Nitrodroid 2013 - Closing ReportPrajyot Mainkar
 
Building Hybrid Applications using PhoneGap
Building Hybrid Applications using PhoneGapBuilding Hybrid Applications using PhoneGap
Building Hybrid Applications using PhoneGapPrajyot Mainkar
 
Android Cloud to Device Messaging Framework
Android Cloud to Device Messaging FrameworkAndroid Cloud to Device Messaging Framework
Android Cloud to Device Messaging FrameworkPrajyot Mainkar
 
Evolution google-android play
Evolution google-android playEvolution google-android play
Evolution google-android playPrajyot Mainkar
 
Steps to install android
Steps to install androidSteps to install android
Steps to install androidPrajyot Mainkar
 

Plus de 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
 

Dernier

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Dernier (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Android Tutorials - Powering with Selection Widget

  • 1. Android.Widgets Tutorial 2 : Powering with Selection Widget By: Mr.PrajyotMainkar MS Software Systems( BITS-Pilani) BE(Hons.) Computer Engineering , PMP( IIT Delhi) S
  • 2. Spinner– The resource pool Spinner is a widget similar to a drop down list selecting items. Here is the xml file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/selection" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Spinner android:id="@+id/spinner" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="true" /> </LinearLayout>
  • 3. Spinner– The resource pool Java File will contain following code package com.spinner; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; public class SpinnerActivity extends Activity implements AdapterView.OnItemSelectedListener { TextView selection; String[] items={"Prajyot", "Prakash", "Mainkar"}; //Continued on next slide
  • 4. Spinner– The resource pool public void onCreate(BundlesavedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.main); selection=(TextView)findViewById(R.id.selection); Spinner spin=(Spinner)findViewById(R.id.spinner); spin.setOnItemSelectedListener(this); ArrayAdapter<String>aAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, items); aAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); spin.setAdapter(aAdapter); } public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { selection.setText(items[position]); } public void onNothingSelected(AdapterView<?> parent) { selection.setText(""); } }
  • 5. Spinner– The resource pool The following output is obtained when you run the code via emulator.
  • 6. Spinner– The resource pool The following output is obtained when you run the code via emulator. The radio button can be replaced by checkboxes.
  • 7. GridView – Roar Louder GridView is a ViewGroup that displays items in a 2-D,scrollable grid. The grid items get inserted automatically to the layout using a ListAdapter <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/selection" android:layout_width="fill_parent" android:layout_height="wrap_content" />
  • 8. GridView– Roar Louder ..Continued from previous slide. <GridView android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:verticalSpacing="40px" android:horizontalSpacing="10px" android:numColumns="auto_fit" android:columnWidth="100px" android:stretchMode="columnWidth" android:gravity="center" /> </LinearLayout>
  • 9. GridView– Roar Louder Java File will contain following code package com.Grid; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.GridView; import android.widget.TextView; public class GridActivity extends Activity implements AdapterView.OnItemSelectedListener { TextView selection; String[] items={"Goa", "Maharashtra", "TamilNadu", "Rajasthan", "Gujrat", "MP", "Karnataka", "Kerala", "Delhi", "AndraPradesh", "Assam", "Manipur", "Orissa", "Punjab", "J&K", "Himachal Pradesh", "West Bengal", "Tripura", "Uttarakhand", "Sikkim", "Bihar", "ArunachalP", "Chhattisgarh", "D&D", "Pondicherry"};
  • 10. GridView– Roar Louder public void onCreate(BundlesavedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);selection=(TextView)findViewById(R.id.selection); GridViewg=(GridView) findViewById(R.id.grid); g.setAdapter(newFunnyLookingAdapter(this, android.R.layout.simple_list_item_1,items)); g.setOnItemSelectedListener(this); } public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { selection.setText(items[position]); } public void onNothingSelected(AdapterView<?> parent) { selection.setText(""); }
  • 11. GridView– Roar Louder private class FunnyLookingAdapter extends ArrayAdapter { Context ctxt; FunnyLookingAdapter(Contextctxt, int resource, String[] items) { super(ctxt, resource, items); this.ctxt=ctxt; } public View getView(int position, View convertView, ViewGroup parent) { TextView label=(TextView)convertView; if (convertView==null) { convertView=new TextView(ctxt); label=(TextView)convertView; } label.setText(items[position]); return(convertView); } } }
  • 12. GridView – Roar Louder The following output is obtained when you run the code via emulator.
  • 13. AutoComplete – Intelligence way Allows to suggest the remaining text-type using the intelligent way .Suggestions are received from a collection of strings associated with the widget through ArrayAdapter <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" > <TextView android:id="@+id/selection" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="States" /> <AutoCompleteTextViewandroid:id="@+id/edit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:completionThreshold="3"/> </LinearLayout>
  • 14. AutoComplete – Intelligence way Java File will contain following code package com.AutoComplete; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.TextView; public class AutoCompleteActivity extends Activity implements TextWatcher { TextView selection; AutoCompleteTextView edit; String[] items={"Goa", "Maharashtra", "TamilNadu", "Rajasthan", "Gujrat", "MP", "Karnataka", "Kerala", "Delhi", "AndraPradesh", "Assam", "Manipur", "Orissa", "Punjab", "J&K", "Himachal Pradesh", "West Bengal", "Tripura", "Uttarakhand", "Sikkim", "Bihar", "ArunachalP", "Chhattisgarh", "D&D", "Pondicherry"};
  • 15. AutoComplete – Intelligence way public void onCreate(BundlesavedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.main); selection=(TextView)findViewById(R.id.selection); edit=(AutoCompleteTextView)findViewById(R.id.edit); edit.addTextChangedListener(this); edit.setAdapter(newArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items)); } public void onTextChanged(CharSequences, int start, int before, int count) { selection.setText(edit.getText()); } public void beforeTextChanged(CharSequences, int start, int count, int after) { // used in case if interface } public void afterTextChanged(Editables) { // used in case if interface } }
  • 16. AutoComplete – Intelligence way The following output is obtained when you run the code via emulator.
  • 17. Thank you.. GET IN TOUCH– Tune Up RadioButton Phone: +91-9822987513 facebook.com/prajyotmainkar Email: twitter.com/prajyotm prajyotm@msn.com