Android - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Android

Description:

Spinner. Displays a single item at a time from a bound list, inside a one-row textbox. ... Load a Spinner and bind it to a data query. ... – PowerPoint PPT presentation

Number of Views:287
Avg rating:3.0/5.0
Slides: 14
Provided by: ccc7
Category:
Tags: android | spinner

less

Transcript and Presenter's Notes

Title: Android


1
Android ??????
2
????
  • View
  • ViewGroup
  • widgets

3
(No Transcript)
4
Layout
  • FrameLayout
  • AbsoluteLayout
  • LinearLayout
  • TableLayout
  • RelativeLayout

5
Frame Layout
  • FrameLayout is the simplest layout object. It is
    intended as a blank reserved space on your screen
    that you can later fill with a single object

6
AbsoluteLayout
  • AbsoluteLayout enables children to specify exact
    x/y coordinates to display on the screen, where
    (0,0) is the upper left corner, and values
    increase as you move down or to the right.
    Margins are not supported, and overlapping
    elements are allowed (although not recommended).
    We generally recommend against using
    AbsoluteLayout unless you have good reasons to
    use it, because it is fairly rigid and does not
    work well with different device displays.

7
Linear Layout
8
Table Layout
9
Relative Layout
10
Summary of Important View Groups
11
AdapterViews (Binding to Data)
  • As we mentioned, some view groups have UI. These
    objects typically subclass AdapterView. Examples
    include such as Gallery (an image selection
    widget) and ListView (a list of views). These
    objects have two jobs in common
  • Filling the layout with data
  • Handling user selections

12
Filling the layout with data
// Get a Spinner and bind it to an
ArrayListAdapter that // references a String
array. private String fruit "apples",
"oranges", "lemons" Spinner s1
(Spinner)findViewById(R.id.fruitlist) s1.setAdapt
er(new ArrayListAdapterltStringgt(this,
mStrings)) // Load a Spinner and bind it to a
data query. private String colsandroid.provide
r.Contacts.PeopleColumns.NAME private Cursor
cur managedQuery(android.provider.Contacts.Peopl
e.CONTENT_URL, cols, null, null) s2.setAdapter(ne
w CursorListAdapter(cur, this))
13
Handling user selections
  • This is done by setting the class's
    AdapterView.OnItemClickListener member to a
    listener and catching the selection changes.

// Create a message handling object as an
anonymous class. private OnItemClickListener
mMessageClickedHandler new OnItemClickListener()
public void onItemClick(AdapterView
parent, View v, int position, long id)
// Display a messagebox.
showAlert("You've got an event", "Clicked me!",
"ok", false) // Now hook into our
object and set its onItemClickListener member //
to our class handler object. mHistoryView
(ListView)findViewById(R.id.accept_button) mHisto
ryView.setOnItemClickListener(mMessageClickedHandl
er)
Write a Comment
User Comments (0)
About PowerShow.com