您的位置:首页 > 移动开发 > Android开发

Android Sample学习——NotePad

2010-08-06 16:12 405 查看
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 into the
Menu
via
MenuInflater
. The easiest way of attaching code to clicks is via
onOptionsItemSelected(MenuItem)
and
onContextItemSelected(MenuItem)
.

Different menu types support different features:

Context menus: Do not support item shortcuts and item icons.

Options menus: The icon menus do not support item check marks and only show the item's
condensed title
. The 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 on
add(int, int, int, CharSequence)
that takes a string resource identifier instead of the string itself.

Parameters
groupId The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use
NONE
if an item should not be in a group.
itemId Unique item ID. Use
NONE
if you do not need a unique ID.
order The order for the item. Use
NONE
if you do not care about the order. See
getOrder()
.
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 shortcut associated with this item. Note that the shortcut will be triggered when the key that generates the given character is pressed alone or along with with the alt key. Also note that case is not significant and that alphabetic shortcut characters will be displayed in lower case.

See
Menu
for the menu types that support shortcuts.

Parameters
numericChar The numeric shortcut key. This is the shortcut 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专题:

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 previously set by
setType(String)
.

Note: scheme and host name matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should 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 calls into 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.

Parameters
action An action name, such as ACTION_VIEW. Application-specific actions should be prefixed with the vendor's package name.
Returns

Returns the same Intent object, for chaining multiple calls into a single statement.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·

android.app.Activity专场:

void android.app.Activity.finish()

public void finish ()

Since: API Level 1

Call this when your activity is done and should 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
, java.lang.String, java.lang.String[], java.lang.String)]query(android.net.Uri, String[], String, String[], String)
that gives the resulting
Cursor
to call
startManagingCursor(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 would like to do processing without those other facilities.

Derived classes should 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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·

android.widget.TextView专场:

public final void setTextKeepState (CharSequence text)

Since: API Level 1

Like
setText(CharSequence)
, except that the cursor position (if any) is retained in the new text.

Parameters
text The new text to place in the text view.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: