Sunday, October 19, 2014

Coursera Android User Interface classes (week 4)

The fourth week covers the User Interface classes. The videos are over an our total in length.


User Interfaces pt1 presentation  & slides

View class - key building block, rectangular space, draw and events
- Button : OnClick()
- ToggleButton : 2 button states, pressed or unpressed
 - CheckBox, 2 state,  checked or not
 - RatingBar, : stars ,  highlight number of stars
AutoCompleteTextView : editable, list of text entries, touch single entry, dont have to scroll thru list

UIAutoComplete Text Entry

View events

set visibility
set checked state
set listeners
set properties

OnClickListener.onClick() , OnLongClickListener.onLongClick(), OnFocusChangeListener.onFocusChange, OnKeyListener.onKey()

view events
- listeners to indiv views
- difft listener types
- OnClick() clicked
- OnLongClick - pressed and held pressed
- OnFocusChange() - lost focus
-OnKeyListener.OnKey() - When a hardware key event is about to be presented to the View.

Measure, Positions,Draws passes


OnKeyUp() OnKeyDown()

User Interface pt 2 presentation

View Groups (compound view) - note that it is a base view for containers or layouts

RadioGroup for range like checkbox or radios that are mutually exclusive UIRadioGroup with textview and radio group, text changes to choice made

TimePicker select a time UITimePicker select button and time picker view group appears
DatePicker UIDatePicker
WebView view group that displays web pages UIWebView
MapView view groups that allows user to interact with them UIGoogleMaps

Adapter View allows you to work with data types i.e. ListView  , child views are managed by Adapter. The Adapter manages the data and provides data views to the AdapterView when it asks for it. AdapterView responsible for displaying the data only.

ListView is an adapter view, scrollable view of selectable items. Its items managed by ListAdapter, can filter items based on text that is input UIListView
call SetListAdapter with is an ArrayAdapter
- /res/layout/list_items.xml defines TextView

Spinner is AdapterView which is scrollable list of items. SpinnerAdapter UISpinner
TextView and Spinner in layout

Gallery horizontally scrolling list data managed with SpinnerAdapter UIGallery

User Interface pt 3 presentation

Layouts - view that contains viewgroup
-LinearLayout arranges children in single row (vert or horiz) UILinearLayout
-RelativeLayout  arranges children relative to each other and their parent UiRelativeLayout
-TableLayout  arranges children in rows and columns UITableLayout
-GridView arrange children in 2 dimensional scrollable grid UIGridLayout , see ImageAdapter which extends BaseAdapter

Menus - access important functions, activities add item to menu. handle clicks example:  HelloAndroidWithMenus -

1)options  menus- older style with menu key, new devices may not have this, global like data OnCreateOptionsMenu, OnOptionsMenuItemSelected

2)context menus -presses and holds view on certain views, page like data

Note: Context Menus are generally associated with individual Views, while Options Menus are generally associated with the entire application.

3)sub menus - secondary menus

Can also have shortcut keys,  group menu items, send Intents on selections of menu items

User Interface pt 4 presentation

Related menu items in group

shortcuts for menu items

Bind Itents to menu items

Action Bar added in 3.0, like a application bar in desktop apps, quick access (file,edit,help), quick access to items they use.


if your application contains a Fragment and that Fragment wants to place actions in the Action Bar
- onCreateOptionsMenu()., setHasOptionsMenu()

ActionBar.Tab - consistent way of switching views, tab area and content area


- OnTabSelected()

-AlertDialog - shows message with Y/N
-ProgressDialog - show you message about state of app progress w fragment

UIAlertDialog - first two dialogs

ToDoItem (domain object)
- public enum Priority { LOW, MED, HIGH };
- public enum Status { NOTDONE, DONE };

ToDoManagerActivity (has adapter of ToDoListAdapter mAdapter) extends ListActivity
- ListActivity.getListView() Get the activity's list view widget.
- ListView.addFooterView(View)
- ListView.setAdapter(ListAdapter)
- LayoutInflater   on footer_view.xml
  •  LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService (Context.LAYOUT_INFLATER_SERVICE);
  • (TextView)inflater.inflate(R.layout.footer_view, null);
  • TextView has method setOnClickListener()

ToDoListAdapter extends BaseAdapter - see Adapter

AddToDoActivity (details in put screen for ToDo)
- sends data input back to calling Activity:
      Intent data = new Intent();       ToDoItem.packageIntent(data, titleString, priority, status, fullDate);         setResult(RESULT_OK, data);       finish();

EditText -  extends TextView

  • setHint() - Sets the text to be displayed when the text of the TextView is empty.
  • setText()
  • check() -  sets the selection to the radio button whose identifier is passed in parameter
  • getCheckedRadioButtonId() -Returns the identifier of the selected radio button in this group.

No comments:

Post a Comment