nullnullHandling the Results 처리 결과
6385 단어 result
CursorLoader
returns its query results to your implementation of LoaderCallbacks.onLoadFinished()
, in the form of a Cursor
. In the callback, you can update your data display, do further processing on the Cursor
data, and so forth. http://blog.csdn.net/sergeycao When the loader framework detects changes to data associated with the query, it resets the
CursorLoader
, closes the current Cursor
, and then invokes your implementation of onLoaderReset()
. Use this callback to delete references to the current Cursor
; 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 a
ListView
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 returned Cursor
to the SimpleCursorAdapter
. Changing the Cursor
in the SimpleCursorAdapter
triggers a refresh of the ListView
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 the Cursor
becomes invalid. This usually occurs because the data associated with the Cursor
has changed. Before re-running the query, the framework calls your implementation of onLoaderReset()
. In this callback, make sure to prevent memory leaks by deleting all references to the current Cursor
. 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);
}
글이 끝나면 프로그래머의 우스갯소리 어록을 공유해 드리겠습니다. 프로그램 언어를 종합해 보면 CLIPPER 프로그래머는 코끼리를 정말 사냥하지 않습니다. 그들은 코끼리 부분의 라이브러리만 구매하고 몇 년 동안 코끼리를 종합하려고 합니다.DBASE 프로그래머는 밤에만 코끼리를 사냥하는데, 왜냐하면 그들이 아직도 석궁을 사용하고 있다는 것을 아무도 알아채지 못하기 때문이다.FOXPRO 프로그래머들은 더 나은 소총을 사용하기 시작했고, 이는 실제 사냥보다 더 많은 시간을 들여 새로운 사격 기술을 배우게 했다.C프로그래머는 소총을 직접 구매하는 것을 거부하고 차라리 강관과 이동식 기계 작업장을 가지고 아프리카로 갈지언정 제로부터 완벽한 소총을 만들려고 한다.PARADOX 프로그래머는 아프리카에 갔을 때 할리우드에서 코끼리 사냥에 관한 영화 시나리오를 가지고 갔는데, 그들은 시나리오대로 하면 코끼리 한 마리를 잡을 수 있다고 생각했다.ACCESS 프로그래머는 코끼리 사냥 경험 없이 출발했다. 그들은 화려한 사냥복을 입고 모든 장비를 챙기고 예쁜 망원경으로 코끼리를 찾은 후 방아쇠를 잊어버린 것을 발견했다.RBASE 프로그래머는 코끼리보다 더 드물다. 사실 코끼리 한 마리가 RBASE 프로그래머를 보았다면 그에게는 행운의 날이었다.VISUAL ACCESS 프로그래머는 총알을 장전하고 소총을 들고 코끼리를 겨냥해 코끼리를 우습게 여겼다. 누가 도망갔는지.그들은 코끼리를 잡을 수 없었다. 왜냐하면 그들은 다중 제어에 대한 선호 때문에, 그들의 지프차는 핸들이 너무 많아서 운전할 수 없었다.ADA, APL, FORTRAN 프로그래머는 산타클로스, 선녀와 마찬가지로 허구였다.COBOL 프로그래머는 자신과 마찬가지로 멸종 위기에 처한 코끼리에게 깊은 동정을 보냈다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
struts2 차단result 관련 정보시나리오: 업무의 수요로 인해namespace의calculator이고 type은layout의 특수한 처리가 필요합니다. 이것은 다음과 같은 설정 파일에 사용되는 차단기가 필요합니다 1、차단 획득 namespace 잘...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.