Customizaiton of Layouts

Slides:



Advertisements
Similar presentations
Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
Advertisements

Unlocking Android Chapter 4.  Understanding activities and views  Exploring the Activity lifecycle  Working with resources  Defining the AndroidManifest.xml.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
User Interface Classes.  Design Principles  Views & Layouts  Event Handling  Menus  Dialogs.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Development (Basics)
Android: Layouts David Meredith
Introducing the Sudoku Example
CS5103 Software Engineering Lecture 08 Android Development II.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Simplify! The Android User Interface
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Android Boot Camp for Developers Using Java, 3E
Nilesh Singh Local Data Storage option Android provides several options for you to save persistent application data. - Shared preferences - Creation.
User Interfaces: Part 1 (View Groups and Layouts).
Configuring Android Development Environment Nilesh Singh.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Copyright© Jeffrey Jongko, Ateneo de Manila University Custom ListAdapters.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
4 Copyright © 2004, Oracle. All rights reserved. Creating a Basic Form Module.
Barnett Trzcinski September 13, Overview Stores a To-Do List Task, Due Date, Completed Persistent on Server Google App Engine.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
CHAPTER 9 File Storage Shared Preferences SQLite.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Java for android Development Nasrullah Khan. Using instanceof in Android Development the classes such as Button, TextView, and CheckBox, which represent.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Why Learn Android? Largest installation base of any operating system Over 20,000 Android devices exist Businesses will likely move more to device-based.
Cosc 4735 Nougat API 24+ additions.
Chapter 2: Simplify! The Android User Interface
Content provider.
Android Content Providers & SQLite
Mobile Applications (Android Programming)
Creating a Basic Form Module
Mobile Application Development BSCS-7 Lecture # 9
Android Application SQLite 1.
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Creation of an Android App By Keith Lynn
Android Development: Advanced Widgets using Adapters
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
ITEC535 – Mobile Programming
Politeknik Elektronika Negeri Surabaya
Data File Import / Export
Lists, Navigation How and why.
HNDIT2417 Mobile Application Development
Android Programming Lecture 6
Android ListView Demo.
ANDROID LISTS.
CS5103 Software Engineering
Android Lists and Fragments
Building User Interfaces Basic Applications
Android Topics Custom ArrayAdapters
CA16R405 - Mobile Application Development (Theory)
Android Topics Limited Resources and why we need to consider them.
HNDIT2417 Mobile Application Development
ListView ? BaseAdapter ?.
ListView A view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view. ListAdapter is used to.
Mobile Programming Dr. Mohsin Ali Memon.
Preference Activity class
CA16R405 - Mobile Application Development (Theory)
CA16R405 - Mobile Application Development (Theory)
Presentation transcript:

Customizaiton of Layouts Android Customizaiton of Layouts

A better task list Use a new Activity-ListActivity Learn about listViews Learn about adapters Learn about some more eclipse refactoring skills.

Task Manager

Cast of characters ListView – a view made for displaying a collection of data in a list of child views. ListActivity – an activity made for managing a ListView, An activity that displays a list of items by binding to a data source such as an array ListAdapter – a class that acts as a dataprovider for a listView.

ListActivity ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code) (as we did in TaskManager Application) Optionally, your custom view can contain another view object of any type to display when the list view is empty. This "empty list" notifier must have an id "android:id/empty". Note that when an empty view is present, the list view will be hidden when there is no data to display

Diff between android:gravity and android:layout_gravity android:gravity positions the contents of that view (i.e. what’s inside the view), whereas android:layout_gravity positions the view with respect to its parent (i.e. what the view is contained in).

Refactoring:Extracting Android String Very nice way to put a String into Android XML and extract it to res/values/strings.xml.

Step-one (the listView)

Listview ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list

No Data View Steps

Show the tasks STEP 2

How a ListAdapter supports a listVies

Show Tasks Steps

Why I should create CustomLayout??? The number of rows to be present on the screen is to be decided dynamically as per the tasks stored in the array.. So i cannot hard code the complete view in XML.

Context class As the name suggests, its the context of current state of the application/object. It lets newly created objects understand what has been going on. Typically you call it to get information regarding another part of your program (activity, package/application) You can get the context by invoking getApplicationContext(), getContext(), getBaseContext() or this (when in the activity class). Typical uses of context: 1)Creating New objects: Creating new views, adapters, listeners: TextView tv = new TextView(getContext()); ListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), ...); 2)Accessing Standard Common Resources: Services like LAYOUT_INFLATER_SERVICE, SharedPreferences: context.getSystemService(LAYOUT_INFLATER_SERVICE) getApplicationContext().getSharedPreferences(*name*, *mode*); 3)Accessing Components Implicitly: Regarding content providers, broadcasts, intent getApplicationContext().getContentResolver().query(uri, ...);

Android:checkmark Drawable used for the check mark graphic. Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name". Constant Value: 16843016 (0x01010108)

@+id/android:list and @+id/list Resource IDs in Android are specific to a package (which is good, or else you'd have lots of conflicts if your app is dealing with several packages at the same time). @+id/list will create a resource ID in your app (=your package) with the name "list" and give it a unique ID. In code, that would be R.id.list. @android:id/list will use the ID "list" from the package android (which, in code, would beandroid.R.id.list