Download presentation
Presentation is loading. Please wait.
1
Customizaiton of Layouts
Android Customizaiton of Layouts
2
A better task list Use a new Activity-ListActivity
Learn about listViews Learn about adapters Learn about some more eclipse refactoring skills.
3
Task Manager
4
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.
5
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 (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
6
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).
7
Refactoring:Extracting Android String
Very nice way to put a String into Android XML and extract it to res/values/strings.xml.
8
Step-one (the listView)
9
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
10
No Data View Steps
11
Show the tasks STEP 2
12
How a ListAdapter supports a listVies
14
Show Tasks Steps
15
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.
16
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, ...);
17
Android:checkmark Drawable used for the check mark graphic.
Must be a reference to another resource, in the form or to a theme attribute in the form "?[package:][type:]name". Constant Value: (0x )
18
@+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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.