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

Similar documents
Practical 1.ListView example

Creating a Custom ListView

Meniu. Create a project:

Mobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

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

Accelerating Information Technology Innovation

Android Using Menus. Victor Matos Cleveland State University

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

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

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

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

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

ANDROID USER INTERFACE

Preferences. Marco Ronchetti Università degli Studi di Trento

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

Graphical User Interfaces

Android Using Menus. Victor Matos Cleveland State University

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

Intents. Your first app assignment

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

Android Data Storage

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

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

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

Starting Another Activity Preferences

Basic GUI elements - exercises

Adapter.

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

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

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

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

ListView Containers. Resources. Creating a ListView

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

Embedded Systems Programming - PA8001

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:

Developing Android Applications

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

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

android:layout_margintop="5dp" > <EditText android:layout_width="210dp"

1. Simple List. 1.1 Simple List using simple_list_item_1

Distributed Systems 2011 Assignment 1

Android Application Model I

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

Arrays of Buttons. Inside Android

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

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

Saving application preferences

Interface ใน View class ประกอบด วย

Android Programs Day 5

Distributed Systems Assignment 1

Lecture 14. Android Application Development

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

Topics of Discussion

Solving an Android Threading Problem

Android Beginners Workshop

Have a development environment in 256 or 255 Be familiar with the application lifecycle

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Android HelloWorld - Example. Tushar B. Kute,

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

Android Workshop: Model View Controller ( MVC):

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Simple Currency Converter

Android UI: Overview

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases.

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

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"

Manifest.xml. Activity.java

Database Development In Android Applications

Android Layout Types

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

Distributed Systems Assignment 1

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Mobile and Ubiquitous Computing: Android Programming (part 3)

GUI Widget. Lecture6

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

App Development for Smart Devices. Lec #18: Advanced Topics

More Effective Layouts

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

Notification mechanism

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Mobile Computing Practice # 2c Android Applications - Interface

Android UI Development

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

DEPARTMENT OF COMPUTER SCIENCE THE UNIVERSITY OF HONG KONG. CSIS0801 Final Year Project. WhozzUp - A Novel Big Data App for HK (Individual Report)

Chapter 8 Positioning with Layouts

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

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

Mobile Computing Practice # 2a Android Applications - Interface

UI (User Interface) overview Supporting Multiple Screens Touch events and listeners

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

Android CardView Tutorial

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


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

05. RecyclerView and Styles

Learn about Android Content Providers and SQLite

Transcription:

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 3

ListView <ListView android:layout_height="wrap_content" android:id="@+id/listview1" android:layout_width="fill_parent" android:entries="@array/days" /> Presenting elements, given in an array onclicklistener onlongclicklistener Jonathan Diehl, Hendrik Thüs 4

Jonathan Diehl, Hendrik Thüs 5 ListView

Jonathan Diehl, Hendrik Thüs 6 ArrayAdapter

ArrayAdapter (1) Create a ListItem (2) Implement an object (3) Implement an ArrayAdapter (4) Combine everything Jonathan Diehl, Hendrik Thüs 7

<LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="wrap_content"> ListItem <LinearLayout android:id="@+id/linearlayout09" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/itemdone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:drawable/presence_online"> </ImageView> <TextView android:id="@+id/itemsubject" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="subject" android:textstyle="bold" android:textsize="20dp" android:textcolor="#ffffff"> </TextView> </LinearLayout> <TextView android:id="@+id/itemtext" android:layout_width="wrap_content" android:text="text" android:layout_height="wrap_content" android:layout_marginleft="15dp" android:textsize="11dp" android:textcolor="#cdcdcd"> </TextView> </LinearLayout> Jonathan Diehl, Hendrik Thüs 8

public class Task { private String subject; private String text; private Boolean done; Object public Task(String subject, String text, Boolean done) { this.subject = subject; this.text = text; this.done = done; public String getsubject() { return subject; public void setsubject(string subject) { this.subject = subject; public String gettext() { return text; public void settext(string text) { this.text = text; public Boolean getdone() { return done; public void setdone(boolean done) { this.done = done; Jonathan Diehl, Hendrik Thüs 9

ArrayAdapter public class TaskOrderAdapter extends ArrayAdapter<Task> { private ArrayList<Task> items; private Context context; public TaskOrderAdapter(Context context, int textviewresourceid, ArrayList<Task> items) { super(context, textviewresourceid, items); this.items = items; this.context = context; public void setitems(arraylist<task> items) { this.items = items; Jonathan Diehl, Hendrik Thüs 10

@Override public View getview(int position, View convertview, ViewGroup parent) { View v = convertview; if (v == null) { LayoutInflater vi = (LayoutInflater) context.getsystemservice(context.layout_inflater_service); v = vi.inflate(r.layout.tasklistitem, null); Task task = items.get(position); if (task!= null) { [Looking for child views: itemdone, itemsubject, itemtext] if (itemdone!= null) { if (task.getdone()) { itemdone.setbackgroundresource( android.r.drawable.presence_online); else { itemdone.setbackgroundresource( android.r.drawable.presence_busy); if (itemsubject!= null) { itemsubject.settext(task.getsubject()); if (itemtext!= null) { itemtext.settext(task.gettext()); return v; Jonathan Diehl, Hendrik Thüs 11

public class main extends Activity { public static TaskOrderAdapter adapter = null; private ArrayList<Task> taskarray; /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Activity taskarray = new ArrayList<Task>(); Task task1 = new Task("Subject1", "Text1", true); Task task2 = new Task("Subject2", "Text2", false); Task task3 = new Task("Subject3", "Text3", true); Task task4 = new Task("Subject4", "Text4", false); taskarray.add(task1); taskarray.add(task2); taskarray.add(task3); taskarray.add(task4); ListView tasklist = (ListView) findviewbyid(r.id.tasklist);... adapter = new TaskOrderAdapter(main.this, R.layout.tasklistitem,taskArray); tasklist.setadapter(adapter); Jonathan Diehl, Hendrik Thüs 12

onclicklistener tasklist.setonitemclicklistener(new OnItemClickListener() { public void onitemclick(adapterview<?> a, View v, int position, long id) { Toast.makeText(getApplicationContext(), taskarray.get(position).getsubject(), Toast.LENGTH_SHORT).show(); ); Jonathan Diehl, Hendrik Thüs 13

ContextMenu registerforcontextmenu(tasklist); @Override public void oncreatecontextmenu(contextmenu menu, View v, ContextMenuInfo menuinfo) { if (v.getid() == R.id.taskList) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuinfo; menu.setheadertitle(taskarray.get(info.position).getsubject()); String[] menuitems = getresources().getstringarray(r.array.taskscontextmenu); for (int i = 0; i < menuitems.length; i++) { menu.add(menu.none, i, i, menuitems[i]); @Override public boolean oncontextitemselected(menuitem item) { int menuitemindex = item.getitemid(); AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getmenuinfo(); if (menuitemindex == 0) { Toast.makeText(this, "show " + taskarray.get(info.position).getsubject(), Toast.LENGTH_SHORT).show(); else if (menuitemindex == 1) { Toast.makeText(this, "delete " + taskarray.get(info.position).getsubject(), Toast.LENGTH_SHORT).show(); return true; Jonathan Diehl, Hendrik Thüs 14

Jonathan Diehl, Hendrik Thüs 15 Android Specifics

Preferences Jonathan Diehl, Hendrik Thüs 16

Preferences Primitive data-sets Key-value pairs Kept private Persists killing the application DON'T use SharedPreferences as database or for large data-sets Jonathan Diehl, Hendrik Thüs 17

Jonathan Diehl, Hendrik Thüs 18 Xml for Preferences

Xml Content <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="category 1"> <CheckBoxPreference android:title="checkbox 1" android:key="item1"></checkboxpreference> <EditTextPreference android:dependency="item1" android:title="edittext1" android:key="item2"></edittextpreference> </PreferenceCategory> </PreferenceScreen> Jonathan Diehl, Hendrik Thüs 19

Jonathan Diehl, Hendrik Thüs 20 PreferenceActivity

PreferenceActivity public class Preferences extends PreferenceActivity { /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.preferences); Jonathan Diehl, Hendrik Thüs 21

Combining everything SharedPreferences preferences; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); preferences = PreferenceManager.getDefaultSharedPreferences(this); i = new Intent(main.this, Preferences.class); startactivity(i); Jonathan Diehl, Hendrik Thüs 22

Retrieving Preferences Boolean checkbox1 = preferences.getboolean("item1", false); String edittext1 = preferences.getstring("item2", "n/a"); Jonathan Diehl, Hendrik Thüs 23

Widgets Jonathan Diehl, Hendrik Thüs 24

Jonathan Diehl, Hendrik Thüs 25 http://www.techrepublic.com/photos/15-must-have-widgets-for-android/452087

Design Guidelines Jonathan Diehl, Hendrik Thüs 26 http://developer.android.com/guide/practices/ui_guidelines/widget_design.html

Sizes - Portrait Jonathan Diehl, Hendrik Thüs 27 http://developer.android.com/guide/practices/ui_guidelines/widget_design.html

Jonathan Diehl, Hendrik Thüs 28 Sizes - Landscape

Sizes Portrait (per cell): 80 pixels wide 100 pixels tall Landscape (per cell): 106 pixels wide 74 pixels tall Jonathan Diehl, Hendrik Thüs 29

Sizes - Worst Case (number of cells * 74) 2 dp Jonathan Diehl, Hendrik Thüs 30

9-patch Images Jonathan Diehl, Hendrik Thüs 31 http://developer.android.com/guide/developing/tools/draw9patch.html

Create an App Widget (1) Layout of the Widget (2) Layout of the configuration (3) AppWidget Provider meta file (4) AppWidgetProvider (5) Activity to handle configuration Jonathan Diehl, Hendrik Thüs 32

Jonathan Diehl, Hendrik Thüs 33 Layouts

AppWidget Provider meta file Jonathan Diehl, Hendrik Thüs 34

AppWidget Provider meta file <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="146dp" android:minheight="72dp" android:initiallayout="@layout/widget" android:configure="de.test.widget.widgetconfiguration"> </appwidget-provider> Jonathan Diehl, Hendrik Thüs 35

Jonathan Diehl, Hendrik Thüs 36 Widget

xcode What are questions concerning xcode? If you think of more, email Jonathan Jonathan Diehl, Hendrik Thüs 37