Session on Android. View. Menu
Interface for managing the items in a menu.
By default, every activity supports an options menu of actions or options. you can add items to this menu and handle clicks on your additions. the easiest way of adding menu items is inflating an XML file intoMenu
ViaMenuInflater
. The easiest way of attaching code to clicks isonOptionsItemSelected(MenuItem)
AndonContextItemSelected(MenuItem)
.
Different menu types support different features:
- Context menus: Do not support item shortcuts and item icons.
- Options menus:Icon menusDo not support item check marks and only show the item's
condensed title
.Expanded menus(Only available if six or more menu items are visible, reached via the 'more' item in the icon menu) do not show item icons, and item check marks are discouraged.
- Sub menus: Do not support item icons, or nested sub menus.
Public abstract menuitem add (INT groupid, int Itemid, int order, int titleres) since: API Level 1
Variation onadd(int, int, int, CharSequence)
That takes a string resource identifier instead of the string itself.
Parameters
Groupid |
The Group Identifier that this item shocould be part of. This can also be used to define groups of items for batch state changes. normally useNONE If an item shoshould not be in a group. |
Itemid |
Unique item ID. UseNONE If you do not need a unique ID. |
Order |
The order for the item. UseNONE If you do not care about the order. SeegetOrder() . |
Titleres |
Resource Identifier of title string. |
Returns
- The newly added menu item.
Public abstract menuitem setshortcut (char numericchar, char alphachar) since: API Level 1
Change both the numeric and alphabetic cut associated with this item. note that the specified cut will be triggered when the key that generates the given character is pressed alone or along with the Alt key. also note that case is not significant and that alphabetic character cut characters will be displayed in lower case.
SeeMenu
For the menu types that support shortcuts.
Parameters
Numericchar |
The numeric shortcut cut key. This is the specified cut when using a numeric (e.g., 12-key) keyboard. |
Alphachar |
The alphabetic shortcut key. This is the shortcut when using a keyboard with alphabetic keys. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Android. Graphics. rect
Rect holds four integer coordinates for a rectangle. the rectangle is represented by the coordinates of its 4 edges (left, top, right bottom ). these fields can be accessed directly. use width () and height () to retrieve the rectangle's width and height. note: Most methods do not check to see that the coordinates are sorted correctly (I. e. left <= right and top <= bottom ).
Android. Graphics. Paint
The paint class holds the style and color information about how to draw geometries, text and bitmaps.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
Android. content. Intent topics:
Uri Android. content. Intent. getdata ()
Public URI getdata () since: API Level 1
Retrieve data this intent is operating on. this URI specifies the name of the data; often it uses the content: Scheme, specifying data in a content provider. other schemes may be handled by specific activities, such as http: by the web browser.
Returns
- The URI of the data this intent is targeting or null.
Public intent setdata (URI data) since: API Level 1
Set the data this intent is operating on. This method automatically clears any type that was previusly setsetType(String)
.
Note: Scheme and host name matching in the android framework is case-sensitive, unlike the formal RFC. as a result, you shoshould always ensure that you write your URI with these elements using lower case letters, and normalize any Uris you receive from outside of Android to ensure the scheme and host is lower case.
Parameters
Data |
The URI of the data this intent is now targeting. |
Returns
- Returns the same intent object, for chaining multiple callinto a single statement.
Public static final string action_insert since: API Level 1
Activity action: insert an empty item into the given container.
Input:getData()
Is URI of the directory (VND. Android. cursor. DIR/*) in which to place the data.
Output: URI of the new data that was created.
Constant Value: "android. Intent. Action. Insert"
Public intent setaction (string action) since: API Level 1
Set the general action to be performed med.
Parameters
Action |
An action name, such as action_view. application-specific actions shoshould be prefixed with the vendor's package name. |
Returns
- Returns the same intent object, for chaining multiple callinto a single statement.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ ·
Session on Android. App. activity:
Void Android. App. activity. Finish ()
Public void finish () since: API Level 1
Call this when your activity is done and shocould be closed. The activityresult is propagated back to whoever launched you via onactivityresult ().
Public final void setresult (INT resultcode, intent data) since: API Level 1
Call this to set the result that your activity will return to its caller.
Parameters
Resultcode |
The result code to propagate back to the originating activity, often result_canceled or result_ OK |
Data |
The data to propagate back to the originating activity. |
Public void setcontentview (INT layoutresid) since: API Level 1
Set the activity content from a layout resource. The resource will be inflated, adding all top-level views to the activity.
Parameters
Layoutresid |
Resource ID to be inflated. |
Public final cursor managedquery (URI Uri, string [] projection, string selection, string [] selectionargs, string sortorder) since: API Level 1
Wrapper around undquery(android.net.Uri, String[], String, String[], String)
That gives the resultingCursor
To callstartManagingCursor(Cursor)
So that the activity will manage its lifecycle for you.
Parameters
Uri |
The URI of the content provider to query. |
Projection |
List of columns to return. |
Selection |
SQL WHERE clause. |
Selectionargs |
The arguments to selection, if any? S are pesent |
Sortorder |
SQL order by clause. |
Returns
- The cursor that was returned by query ().
Public void settitle (charsequence title) since: API Level 1
Change the title associated with this activity. if this is a top-level activity, the title for its window will change. if it is an embedded activity, the parent can do whatever it wants with it.
Public Boolean onoptionsitemselected (menuitem item) since: API Level 1
This hook is called whenever an item in your options menu is selected. the default implementation simply returns false to have the normal processing happen (calling the item's runnable or sending a message to its handler as appropriate ). you can use this method for any items for which you wocould like to do processing without those other facilities.
Derived classes shocould call through to the base class for it to perform the default menu handling.
Parameters
Item |
The menu item that was selected. |
Returns
- Boolean return false to allow normal menu processing to proceed, true to consume it here.
Public intent getintent () since: API Level 1
Return the intent that started this activity.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ ·
Session on Android. widget. textview:
Public final void settextkeepstate (charsequence text) since: API Level 1
LikesetText(CharSequence)
, Until t that the cursor position (if any) is retained in the new text.
Parameters
Text |
The new text to place in the text view. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ Session on Android. database. cursor: String Android. database. cursor. getstring (INT columnindex)
Public abstract string getstring (INT columnindex) since: API Level 1
Returns the value of the requested column as a string.
If the native content of that column is not text the result will be the result of passing the column value to string. valueof (X ).
Parameters
Columnindex |
The zero-based index of the target column. |
Returns
- The value of that column as a string.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
Android. content. contentvalues:
Void Android. content. contentvalues. Put (string key, string value)
Public void put (string key, string value) since: API Level 1
Adds a value to the set.
Parameters
Key |
The name of the value to put |
Value |
The data for the value to put |