Adapter.

Size: px
Start display at page:

Download "Adapter."

Transcription

1 1

2 Adapter An Adapter object acts as a bridge between an AdapterView and the underlying data for that view The Adapter provides access to the data items The Adapter is also responsible for making a View for each item in the data set Adapters provide a common interface to the data model behind a selection-style widget, such as a listbox, spinner etc 2

3 Use of Adapter Android's adapters are responsible for providing the roster of data for widgets/views plus converting individual elements of data into specific views to be displayed inside the widget/views The adapter is assigned to the View via the setadapter method on the View object. An adapter extend the BaseAdapter class. Android provides some standard adapters. The most important are ArrayAdapter and CursorAdapter. 3

4 Types of Adapters Base Adapter ArrayAdapter SimpleAdapter CursorAdapter SimpleCursorAdapter 4

5 BaseAdapter is an abstract base class for the Adapter interface to simplify implementing adapters You could implement your own, but the framework provides some pretty flexible adapters already 5

6 Array Adapter Binds an array of data to a view override getview() to inflate, populate, and return a custom view for the given index in the array. The getview() method includes an opportunity to reuse views via the convertview parameter. 6

7 Using ArrayAdapter The ArrayAdapter can handle Java array or java.util.list as input eg String[] items={"this", "is", "a","really", "silly", "list"}; new ArrayAdapter<String>(this, android.r.layout.simple_list_item_1, items); 7

8 ArrayAdapter constructor takes three parameters: The Context to use (typically this will be your activity instance) The resource ID of a view to use (such as a built-in system resource ID, as shown above) The actual array or list of items to use 8

9 Backing the list as an ArrayList of Maps Each entry in ArrayList corresponds to an row The Maps contains the data for each column 9

10 ArrayList<HashMap<String,Object>> listdata=new ArrayList<HashMap<String,Object>>(); for (int i=0;i<3;i++) { HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("title", "title"); hm.put("context", "context"); listdata.add(hm); } String[] from = {"title", "context"}; int[] to={r.id.title,r.id.context}; SimpleAdapter adapter = new SimpleAdapter(this, listdata, R.layout.list_item, from, to); 10

11 Cursor Adapter Binds data from a cursor (like a database cursor) to a view Abstract so you don't use it directly, use a subclass or derive your own Implement the abstract method newview() to inflate, populate, and return the desired view for the current cursor position Implement the abstract method bindview() to populate an existing view that is being reused 11

12 Simple Cursor Adapter Concrete implementation of CursorAdapter It can take a row layout and a mapping of cursor columns to row layout widgets Supports text and images, but can customize using setviewtext and setviewimage Can support other types and can customize bindings through a hook 12

13 An adapter needs to know the following in its constructor //the context in which it will operate (required) //the source data (required) //the list item layout (required) //the target fields -- if more than one. //cursor if this is a cursoradapter //you must then set the adapter to the Target View 13

14 Adapter View: Class Diagram 14

15 AdapterView An AdapterView is a view whose children are determined by an Adapter. Commonly used subclasses of Adapterview are as follows: Spinner ListView Gallery Grid View 15

16 Spinner In Android, the Spinner is the equivalent of the drop-down selector you might find in other toolkits (e.g., JComboBox in Java/Swing) Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value You can add a spinner to your layout with the Spinner object. You should usually do so in your XML layout with a <Spinner> element. 16

17 Spinner In Android, the Spinner is the equivalent of the drop-down selector you might find in other toolkits (e.g., JComboBox in Java/Swing) Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value You can add a spinner to your layout with the Spinner object. You should usually do so in your XML layout with a <Spinner> element. 17

18 Spinner : Choices population Using XML android:entries (Reference to an array resource) Invoke setadapter to add Choices in spinner. The data may come either from ArrayAdapter, if choices are available in array or from Cursor Adapter, if choices are available in database 18

19 Spinner : Selection When the user selects an item from the dropdown, the Spinner object receives an on-itemselected event and its interface implementation be specified by calling setonitemselectedlistener() To define the selection event handler for a spinner, implement the AdapterView.OnItemSelectedListener interface. This interface requires the onitemselected() and onnothingselected() callback methods 19

20 <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content"/> <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawselectorontop="true"/> </LinearLayout> 20

21 public class SpinnerDemo extends Activity implements AdapterView.OnItemSelectedListener { TextView selection; String[] items= { Table, Chair, Laptop, Mobile, Desktop, File public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); selection=(textview)findviewbyid(r.id.selection); Spinner spin=(spinner)findviewbyid(r.id.spinner); spin.setonitemselectedlistener(this); ArrayAdapter<String> aa=new ArrayAdapter<String>(this, android.r.layout.simple_list_item_1, items); 21

22 aa.setdropdownviewresource( android.r.layout.simple_spinner_dropdown_item); spin.setadapter(aa); } public void onitemselected(adapterview parent, View v, int position, long id) { selection.settext(items[position]); } public void onnothingselected(adapterview parent) { selection.settext(""); } } 22

23 23

24 24

25 ListView The classic listbox widget in Android is known as ListView. Following need to be implemented for listview Include listview in your layout Invoke setadapter() to supply data and child views Attach a listener via setonitemselectedlistener() to find out when the selection has been made 25

26 If activity is dominated by a single list, you might consider creating your activity as a subclass of ListActivity, rather than the regular Activity base class. If main view is just the list, you do not even need to supply a layout ListActivity will construct a full-screen list for you. If you do want to customize the layout, you can, so long as you identify your ListView so ListActivity knows which widget is the main list for the activity 26

27 With ListActivity, you can set the list adapter via setlistadapter() in this case, providing an ArrayAdapter wrapping an array of nonsense strings. To find out when the list selection changes, override onlistitemclick() and take appropriate steps based on the supplied child view and position (in this case, updating the label with the text for that position). 27

28 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content"/> <ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:drawselectorontop="false" /> </LinearLayout> 28

29 public class ListViewDemo extends ListActivity { TextView selection; String[] items= { NeetiKhand", GyanKhand", Shakti Khand", Nyay Khand", Ahinsa Khand", Vaibhav Khand",}; 29

30 @Override public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); Listview List=(ListView)findViewById(R.id.list); setlistadapter(new ArrayAdapter<String>(this, android.r.layout.simple_list_item_1, items)); selection=(textview) findviewbyid(r.id.selection); } public void onlistitemclick(listview parent, View v, int position,long id) { selection.settext(items[position]); } } 30

31 31

32 Custom Adapter & List View Design layout XML file, which will represent one row in the ListView Extend the Adapter class Implement constructor to pass data to sub class Override getview method to map each row with data elements 32

33 Custom Adapter & List public int getcount() { return topic_qcount.length; public Object getitem(int position) { return position; public long getitemid(int position) { return position; public View getview(final int position, View convertview, ViewGroup parent) { } 33

34 Recycle View & Card View 34

35 To create complex lists and cards with material design styles in your apps, you can use the RecyclerView andcardview widgets. The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerViewwidget when you have data collections whose elements change at runtime based on user action or network events. To use the RecyclerView widget, you have to specify an adapter and a layout manager. To create an adapter, extend the RecyclerView.Adapter class. 35

36 RecyclerView provides these built-in layout managers: LinearLayoutManager shows items in a vertical or horizontal scrolling list. GridLayoutManager shows items in a grid. StaggeredGridLayoutManager shows items in a staggered grid. To create a custom layout manager, extend therecyclerview.layoutmanager class. 36

37 To create Recycle View do following steps. You need to import appcompat_v7 library if it is not important by default. 1. Create xml file and add v7.widget.recycleview. 2. Create Main Activity Class & create Custom Adapter Class. 3. Create MyAdapter class & extends RecyclerView.Adapter <MyAdapter.ViewHolder> 4. Create Item Class to show the data in Recycle View. 37

38 Create a xml file and add RecycleView. 38

39 <RelativeLayout xmlns:android=" xmlns:tools=" android:layout_width="fill_parent" android:layout_height="match_parent > <android.support.v7.widget.recyclerview xmlns:android=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" /> </RelativeLayout> 39

40 Create a xml file for item layout 40

41 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=" pk/res/android" android:layout_width="fill_parent" android:layout_height="80dp" > <!-- icon --> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:layout_alignparentleft="true" android:layout_marginleft="8dp" android:layout_marginright="8dp" android:layout_margintop="1dp" android:layout_marginbottom="1dp" android:contentdescription="icon android: /> <!-- title --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" " con" gray" android:layout_marginleft="8dp" android:layout_marginright="8dp" android:layout_margintop="8dp" android:textsize="22dp" /> </RelativeLayout> 41

42 Create Main Activity Class 42

43 public class MainActivity extends Activity protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // 1. get a reference to recyclerview RecyclerView recyclerview = (RecyclerView) findviewbyid(r.id.recyclerview); // this is data fro recycler view ItemData itemsdata[] = { new ItemData("Help",R.drawable.help), new ItemData("Delete",R.drawable.content_discard), new ItemData("Cloud",R.drawable.collections_cloud), new ItemData("Favorite",R.drawable.rating_favorite), new ItemData("Like",R.drawable.rating_good), new ItemData("Rating",R.drawable.rating_important)}; // 2. set layoutmanger recyclerview.setlayoutmanager(new LinearLayoutManager(this)); // 3. create an adapter MyAdapter madapter = new MyAdapter(itemsData); // 4. set adapter recyclerview.setadapter(madapter); // 5. set item animator to DefaultAnimator recyclerview.setitemanimator(new DefaultItemAnimator()); } } 43

44 Create MyAdapter Class & extends RecyclerView.Adapter <MyAdapter. ViewHolder> 44

45 public class MyAdapter extends RecyclerView.Adapter <MyAdapter.ViewHolder> { private ItemData [] itemsdata; public MyAdapter (ItemData[] itemsdata) { this.itemsdata = itemsdata; } // Create new views (invoked by the layout public MyAdapter. ViewHolder oncreateviewholder (ViewGroup parent, int viewtype) { // create a new view View itemlayoutview = LayoutInflater.from (parent.getcontext()).inflate(r.layout.item_layout, null); // create ViewHolder ViewHolder viewholder = new ViewHolder(itemLayoutView); return viewholder; 45

46 } // Replace the contents of a view (invoked by the layout public void onbindviewholder (ViewHolder viewholder, int position) { // - get data from your itemsdata at this position // - replace the contents of the view with that itemsdata } viewholder.txtviewtitle.settext(itemsdata[position].gettitle()); viewholder.imgviewicon.setimageresource(itemsdata[position].getimageurl()); // inner class to hold a reference to each item of RecyclerView public static class ViewHolder extends RecyclerView.ViewHolder { public TextView txtviewtitle; public ImageView imgviewicon; 46

47 } public ViewHolder(View itemlayoutview) { super(itemlayoutview); txtviewtitle = (TextView) itemlayoutview.findviewbyid(r.id.item_title); imgviewicon = (ImageView) itemlayoutview.findviewbyid(r.id.item_icon); } } // Return the size of your itemsdata (invoked by the layout public int getitemcount() { return itemsdata.length; } 47

48 Create a class Item 48

49 public class ItemData { private String title; private int imageurl; public ItemData(String title,int imageurl){ } this.title = title; this.imageurl = imageurl; } // getters & setters 49

50 Run 50

05. RecyclerView and Styles

05. RecyclerView and Styles 05. RecyclerView and Styles 08.03.2018 1 Agenda Intents Creating Lists with RecyclerView Creating Cards with CardView Application Bar Menu Styles and Themes 2 Intents 3 What is Intent? An Intent is an

More information

Creating a Custom ListView

Creating a Custom ListView Creating a Custom ListView References https://developer.android.com/guide/topics/ui/declaring-layout.html#adapterviews Overview The ListView in the previous tutorial creates a TextView object for each

More information

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie The image cannot be displayed. Your computer

More information

List-Based Widgets: Lists, Grids, and Scroll Views

List-Based Widgets: Lists, Grids, and Scroll Views Lesson 5 List-Based Widgets: Lists, Grids, and Scroll Views Victor Matos Cleveland State University Portions of this page are reproduced from work created and shared by Google and used according to terms

More information

Chapter 8 Positioning with Layouts

Chapter 8 Positioning with Layouts Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 8 Positioning with Layouts Chapter 8 Overview Create user interfaces in Android by defining resource files or

More information

ListView (link) An ordered collection of selectable choices. key attributes in XML:

ListView (link) An ordered collection of selectable choices. key attributes in XML: CS 193A Lists This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. ListView (link) An ordered collection

More information

GUI Widget. Lecture6

GUI Widget. Lecture6 GUI Widget Lecture6 AnalogClock/Digital Clock Button CheckBox DatePicker EditText Gallery ImageView/Button MapView ProgressBar RadioButton Spinner TextView TimePicker WebView Android Widgets Designing

More information

Introductory Mobile App Development

Introductory Mobile App Development Introductory Mobile App Development 152-160 Quick Links & Text References Overview Pages ListView Pages ArrayAdaper Pages Filling a ListView Pages Sensing Click Pages Selected Item Info Pages Configuring

More information

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review) EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget

More information

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Programming with Android: Introduction Layouts Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Views: outline Main difference between a Drawable and

More information

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents Mobile Programming Lecture 3 Resources, Selection, Activities, Intents Lecture 2 Review What widget would you use to allow the user to enter a yes/no value a range of values from 1 to 100 What's the benefit

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces Some suggestions Avoid displaying too many things Well-known anti-patterns Display useful content on your start screen Use action bars to provide consistent navigation Keep your

More information

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget

More information

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing

More information

Android List-Based Selection Widgets

Android List-Based Selection Widgets Lesson 6 Android List-Based Selection Widgets Notes are based on: Android Developers http://developer.android.com/index.html Victor Matos Cleveland State University Portions of this page are reproduced

More information

ListView Containers. Resources. Creating a ListView

ListView Containers. Resources. Creating a ListView ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a

More information

Programming with Android: Introduction. Layouts. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Programming with Android: Introduction. Layouts. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Programming with Android: Introduction Layouts Luca Bedogni Dipartimento di Informatica: Scienza e Ingegneria Uniersità di Bologna Views: outline Main difference between a Drawable and a View is reaction

More information

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie User Interface Design" & Development -

More information

Practical 1.ListView example

Practical 1.ListView example Practical 1.ListView example In this example, we show you how to display a list of fruit name via ListView. Android Layout file File : res/layout/list_fruit.xml

More information

Android CardView Tutorial

Android CardView Tutorial Android CardView Tutorial by Kapil - Wednesday, April 13, 2016 http://www.androidtutorialpoint.com/material-design/android-cardview-tutorial/ YouTube Video We have already discussed about RecyclerView

More information

Android Layout Types

Android Layout Types Android Layout Types Android Linear Layout Android LinearLayout is a view group that aligns all children in either vertically or horizontally. android:divider - This is drawable to use as a vertical divider

More information

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Diving into Android. By Jeroen Tietema. Jeroen Tietema, Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com

More information

Lampiran Program : Res - Layout Activity_main.xml

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

More information

ANDROID USER INTERFACE

ANDROID USER INTERFACE 1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed

More information

The World of List View. Romain Guy and Adam Powell May 19, 2010

The World of List View. Romain Guy and Adam Powell May 19, 2010 The World of List View Romain Guy and Adam Powell May 19, 2010 View live notes and ask questions about this session on Wave http://bit.ly/9zozbr Agenda Virtualization and adapters Item properties Headers

More information

1. Simple List. 1.1 Simple List using simple_list_item_1

1. Simple List. 1.1 Simple List using simple_list_item_1 1. Simple List 1.1 Simple List using simple_list_item_1 1. Create the Android application with the following attributes. Application Name: MySimpleList Project Name: Package Name: MySimpleList com.example.mysimplelist

More information

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { }

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { } Android ActionBar import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { Layout, activity.xml

More information

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics ArrayAdapter Preferences Widgets Jonathan Diehl, Hendrik Thüs 2 ArrayAdapter Jonathan Diehl, Hendrik Thüs

More information

Chapter 5 Flashing Neon FrameLayout

Chapter 5 Flashing Neon FrameLayout 5.1 Case Overview This case mainly introduced the usages of FrameLayout; we can use FrameLayout to realize the effect, the superposition of multiple widgets. This example is combined with Timer and Handler

More information

Adapting to Data. Before we get to the fun stuff... Initial setup

Adapting to Data. Before we get to the fun stuff... Initial setup Adapting to Data So far, we've mostly been sticking with a recurring theme: visual elements are tied to XML-defined resources, not programmatic creation or management. But that won't always be the case.

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are

More information

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners Layouts and Views http://developer.android.com/guide/topics/ui/declaring-layout.html http://developer.android.com/reference/android/view/view.html Repo: https://github.com/karlmorris/viewsandlayouts Overview

More information

Building User Interface for Android Mobile Applications II

Building User Interface for Android Mobile Applications II Building User Interface for Android Mobile Applications II Mobile App Development 1 MVC 2 MVC 1 MVC 2 MVC Android redraw View invalidate Controller tap, key pressed update Model MVC MVC in Android View

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Intents. Your first app assignment

Intents. Your first app assignment Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work

More information

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or

More information

Android Basics. Android UI Architecture. Android UI 1

Android Basics. Android UI Architecture. Android UI 1 Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à

More information

User Interface Development in Android Applications

User Interface Development in Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture User Interface Development in Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan

More information

Lesson 5. List-Based Selectors. List-Based Selector: Lists, Grids, and Scroll Views... 3

Lesson 5. List-Based Selectors. List-Based Selector: Lists, Grids, and Scroll Views... 3 Lesson 5. List-Based Selectors List-Based Selector: Lists, Grids, and Scroll Views... 3 List-Based Selector: Lesson 5 Lists, Grids, and Scroll Views Goals Discrete and List-Based Selectors ListViews and

More information

Mobila applikationer och trådlösa nät, HI1033, HT2012

Mobila applikationer och trådlösa nät, HI1033, HT2012 Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

Basic GUI elements - exercises

Basic GUI elements - exercises Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add

More information

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial Hello World Lesson 1 This work is licensed This under work a Creative is is licensed Commons under a a Attribution-NonCommercial Creative 4.0 Commons International Attribution- License 1 NonCommercial

More information

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015 Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional

More information

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are: ETSN05, Fall 2017, Version 1.0 Software Development of Large Systems Lab 2 preparations Read through this document carefully. In order to pass lab 2, you will need to understand the topics presented in

More information

Mobile Computing Practice # 2a Android Applications - Interface

Mobile Computing Practice # 2a Android Applications - Interface Mobile Computing Practice # 2a Android Applications - Interface 1. Create an Android Lunch Places List application that allows the user to take note of restaurant characteristics like its name, address

More information

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics Chapter 10 Speech Recognition 10.1 Introduction Speech recognition (SR) by machine, which translates spoken words into text has been a goal of research for more than six decades. It is also known as automatic

More information

Android UI Development

Android UI Development Android UI Development Android UI Studio Widget Layout Android UI 1 Building Applications A typical application will include: Activities - MainActivity as your entry point - Possibly other activities (corresponding

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu India Summer 2012 Review Session Android and Web Working with Views Working with Views Create a new Android project. The app name should

More information

Produced by. Mobile Application Development. Eamonn de Leastar

Produced by. Mobile Application Development. Eamonn de Leastar Mobile Application Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie A First

More information

CS371m - Mobile Computing. User Interface Basics

CS371m - Mobile Computing. User Interface Basics CS371m - Mobile Computing User Interface Basics Clicker Question Have you ever implemented a Graphical User Interface (GUI) as part of a program? A. Yes, in another class. B. Yes, at a job or internship.

More information

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control. A TextView displays text to the user. TextView Attributes TextView Control android:id - This is the ID which uniquely identifies the control. android:capitalize - If set, specifies that this TextView has

More information

Mobila applikationer och trådlösa nät, HI1033, HT2013

Mobila applikationer och trådlösa nät, HI1033, HT2013 Mobila applikationer och trådlösa nät, HI1033, HT2013 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu Announcements Slight modifications to course timeline posted No class February 16 (Advising day)

More information

Mobile Computing Practice # 2c Android Applications - Interface

Mobile Computing Practice # 2c Android Applications - Interface Mobile Computing Practice # 2c Android Applications - Interface One more step in the restaurants application. 1. Design an alternative layout for showing up in landscape mode. Our current layout is not

More information

ELET4133: Embedded Systems. Topic 15 Sensors

ELET4133: Embedded Systems. Topic 15 Sensors ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects

More information

Android writing files to the external storage device

Android writing files to the external storage device Android writing files to the external storage device The external storage area is what Android knows as the SD card. There is a virtual SD card within the Android file system although this may be of size

More information

Fragment Example Create the following files and test the application on emulator or device.

Fragment Example Create the following files and test the application on emulator or device. Fragment Example Create the following files and test the application on emulator or device. File: AndroidManifest.xml

More information

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based. 1 COS 470 - MOBILE DEVELOPMENT INTRODUCTION 2 WHAT IS ANDROID Linux-based Java/Kotlin Android Runtime (ART) System Apps SMS, Calendar, etc. Platform Architecture 3 CORE OS Linux (64 bit) Each app is a

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop Workshop 1. Create an Option Menu, and convert it into Action Bar (Page 1 8) Create an simple Option Menu Convert Option Menu into Action Bar Create Event Listener for Menu and Action Bar Add System Icon

More information

OPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS

OPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS OPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS @CYRILMOTTIER GET TO KNOW JAVA DON T USE BOXED TYPES UNNECESSARILY HashMap hashmap = new HashMap();

More information

Topics of Discussion

Topics of Discussion Reference CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing Fragments, ActionBar and Menus Part 3 of 5 Android Programming Concepts, by Trish Cornez and Richard Cornez, pubslihed by Jones

More information

Open Lecture Mobile Programming. Intro to Material Design

Open Lecture Mobile Programming. Intro to Material Design Open Lecture Mobile Programming Intro to Material Design Agenda Introduction to Material Design Applying a Material Theme Toolbar/Action Bar Navigation Drawer RecyclerView CardView Support Design Widgets/Tools

More information

Lecture 14. Android Application Development

Lecture 14. Android Application Development Lecture 14 Android Application Development Notification Instructor Muhammad Owais muhammad.owais@riphah.edu.pk Cell: 03215500223 Notifications Used to notify user for events Three general forms of Notifications

More information

Database Development In Android Applications

Database Development In Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran

More information

Action Bar. Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps.

Action Bar. Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps. 1 Action Bar Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps. 1) App Icon 3) Action Buttons 2)View Control 4) Action Overflows

More information

Create Parent Activity and pass its information to Child Activity using Intents.

Create Parent Activity and pass its information to Child Activity using Intents. Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;

More information

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Shared Preferences 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran Tanveer, ITU Experts

More information

Starting Another Activity Preferences

Starting Another Activity Preferences Starting Another Activity Preferences Android Application Development Training Xorsat Pvt. Ltd www.xorsat.net fb.com/xorsat.education Outline Starting Another Activity Respond to the Button Create the

More information

Developing Android Applications

Developing Android Applications Developing Android Applications SEG2105 - Introduction to Software Engineering Fall 2016 Presented by: Felipe M. Modesto TA & PhD Candidate Faculty of Engineering Faculté de Génie uottawa.ca Additional

More information

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 Submitted to: Sir Waqas Asghar MAY 23, 2017 SUBMITTED BY: REHAN ASGHAR Intent in Android What are Intent? An Intent is a messaging object you can use to request

More information

Stanislav Rost CSAIL, MIT

Stanislav Rost CSAIL, MIT Session 2: Lifecycles, GUI Stanislav Rost CSAIL, MIT The Plan 1 Activity lifecycle Service lifecycle 2 Selected GUI elements UI Layouts 3 Hands on assignment: RoboChat Application GUI Design Birth, death,

More information

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator. Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New

More information

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified

More information

Android UI: Overview

Android UI: Overview 1 Android UI: Overview An Activity is the front end component and it can contain screens. Android screens are composed of components or screen containers and components within the containers Screen containers

More information

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Fragments. Lecture 11

Fragments. Lecture 11 Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2 Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu Announcements Group formation: Projects 2, 3 and final project will be

More information

Mobile User Interfaces

Mobile User Interfaces Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00

More information

South Africa

South Africa South Africa 2013 Lecture 6: Layouts, Menus, Views http://aiti.mit.edu Create an Android Virtual Device Click the AVD Icon: Window -> AVD Manager -> New Name & start the virtual device (this may take a

More information

Statistics http://www.statista.com/topics/840/smartphones/ http://www.statista.com/topics/876/android/ http://www.statista.com/statistics/271774/share-of-android-platforms-on-mobile-devices-with-android-os/

More information

Sizing and Positioning

Sizing and Positioning CS 193A Layout This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Sizing and Positioning How does the

More information

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java. Screen Slides References https://developer.android.com/training/animation/screen-slide.html https://developer.android.com/guide/components/fragments.html Overview A fragment can be defined by a class and

More information

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie The image cannot be displayed. Your computer

More information

Android Data Binding: This is the DSL you're looking for

Android Data Binding: This is the DSL you're looking for Android Data Binding: This is the DSL you're looking for Maksim Lin Freelance Android Developer www.manichord.com The plan Why Data Binding? Brief intro to Data Binding Library Adding Data Binding to an

More information

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

android:orientation=horizontal android:layout_margintop=30dp> <Button android:text=button2 Parametrų keitimas veikiančioje aplikacijoje Let s create a project: Project name: P0181_DynamicLayout3 Build Target: Android 2.3.3 Application name: DynamicLayout3 Package name: ru.startandroid.develop.dynamiclayout3

More information

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html

More information

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Let s work with the listener Button button = ; button.setonclicklistener(new.onclicklistener() { public void

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications

More information

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Layouts, Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Components of an Activity ViewGroup: definition

More information

Android DP SDK Integration Guide

Android DP SDK Integration Guide Android DP SDK Integration Guide Requirements Minimum Android Version : Android 4.1 'Jelly Bean' (API level 16) instant Run Removal. (Preferences -> Instant Run -> Unlock to Enable Instant Run) Step 1.

More information

Upon completion of the second part of the lab the students will have:

Upon completion of the second part of the lab the students will have: ETSN05, Fall 2017, Version 2.0 Software Development of Large Systems Lab 2 1. INTRODUCTION The goal of lab 2 is to introduce students to the basics of Android development and help them to create a starting

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Tip: Switching UIs THE PROBLEM How to switch from one UI to another Each UI is associated with a distinct class that controls it Solution shown: two UIs,

More information