編輯:關於Android編程
CursorLoader returns its query results to your implementation ofLoaderCallbacks.onLoadFinished(), in the form of a Cursor. In the callback, you can update your data display, do further processing on theCursor data, and so forth. http://blog.csdn.net/sergeycao
When the loader framework detects changes to data associated with the query, it resets theCursorLoader, closes the current Cursor, and then invokes your implementation ofonLoaderReset(). Use this callback to delete references to the currentCursor; when the loader framework destroys the Cursor, you won't have outstanding references that cause memory leaks.
Handle Query Results
The following two snippets are an example of displaying the results of a query, using aListView backed by a SimpleCursorAdapter.
The first snippet shows the ListView and SimpleCursorAdapter:
// Gets a handle to the Android built-in ListView widget
mListView = ((ListView) findViewById(android.R.id.list));
// Creates a CursorAdapter
mAdapter =
new SimpleCursorAdapter(
this, // Current context
R.layout.logitem, // View for each item in the list
null, // Don't provide the cursor yet
FROM_COLUMNS, // List of cursor columns to display
TO_FIELDS, // List of TextViews in each line
0 // flags
);
// Links the adapter to the ListView
mListView.setAdapter(mAdapter);
The next snippet shows an implementation of onLoadFinished() that moves the query results in the returnedCursor to the SimpleCursorAdapter. Changing theCursor in the SimpleCursorAdapter triggers a refresh of theListView with the new data:
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor)
{
/*
* Move the results into the adapter. This
* triggers the ListView to re-display.
*/
mAdapter.swapCursor(cursor);
}
Handle a Loader Reset
The loader framework resets the CursorLoader whenever theCursor becomes invalid. This usually occurs because the data associated with theCursor has changed. Before re-running the query, the framework calls your implementation ofonLoaderReset(). In this callback, make sure to prevent memory leaks by deleting all references to the currentCursor. Once you return from onLoaderReset(), the loader framework re-runs the query.
For example:
public void onLoaderReset(Loader<Cursor> loader)
{
// Remove the reference to the current Cursor
mAdapter.swapCursor(null);
}
一.前言第一次做導航時,並沒有關注語音播報,今天特意把這個功能完善一下。但是發現關於語音播報的實現也遇到了一些問題,在官方的討論區也發現關於語音播報的問題特別多,問題基本
在這篇微信公眾平台開發教程中,我們將介紹如何在網頁中實現獲取收貨地址的功能。收貨地址共享接口 在2016年4月13日 進行過升級,2016年5月20日之後只能使用新接口,
1.自定義控件時鐘的布局和Java類values文件下的attrs.xml <!--?xml version="1.0" encoding=&q
作為Android開發者,工作中少不了要反編譯別人的apk,當然主要目的還是為了學習到更多,取彼之長,補己之短。今天就來總結一下Android反編譯和二次打包的一些知識。