Android Sample学习——NotePad

 
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:

  1. Context menus: Do not support item shortcuts and item icons.
  2. 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.
  3. 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 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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
List of Sample Apps The list below provides a summary of the sample applications that are available with the Android SDK. Using the links on this page, you can view the source files of the sample applications in your browser. You can also download the source of these samples into your SDK, then modify and reuse it as you need. For more information, see Getting the Samples. API Demos A variety of small applications that demonstrate an extensive collection of framework topics. Backup and Restore A simple example that illustrates a few different ways for an application to implement support for the Android data backup and restore mechanism. Bluetooth Chat An application for two-way text messaging over Bluetooth. BusinessCard An application that demonstrates how to launch the built-in contact picker from within an activity. This sample also uses reflection to ensure that the correct version of the contacts API is used, depending on which API level the application is running under. Contact Manager An application that demonstrates how to query the system contacts provider using the ContactsContract API, as well as insert contacts into a specific account. Home A home screen replacement application. JetBoy A game that demonstrates the SONiVOX JET interactive music technology, with JetPlayer. Live Wallpaper An application that demonstrates how to create a live wallpaper and bundle it in an application that users can install on their devices. Lunar Lander A classic Lunar Lander game. Multiple Resolutions A sample application that shows how to use resource directory qualifiers to provide different resources for different screen configurations. Note Pad An application for saving notes. Similar (but not identical) to the Notepad tutorial. SampleSyncAdapter Demonstrates how an application can communicate with a cloud-based service and synchronize its data with data stored locally in a content provider. The sample uses two related parts of the Android framework — the account manager and the synchronization manager (through a sync adapter). Searchable Dictionary A sample application that demonstrates Android's search framework, including how to provide search suggestions for Quick Search Box. Snake An implementation of the classic game "Snake." Soft Keyboard An example of writing an input method for a software keyboard. Spinner A simple application that serves as an application-under-test for the SpinnerTest sample application. SpinnerTest An example test application that contains test cases run against the Spinner sample application. To learn more about the application and how to run it, please read the Activity Testing tutorial. TicTacToeLib An example of an Android library project that provides a game-play Activity to any dependent application project. For an example of how an application can use the code and resources in an Android library project, see the TicTacToeMain sample application. TicTacToeMain An example of an Android application that makes use of code and resources provided in an Android library project. Specifically, this application uses code and resources provided in the TicTacToeLib library project. Wiktionary An example of creating interactive widgets for display on the Android home screen. Wiktionary (Simplified) A simple Android home screen widgets example.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值