blob: b6d277f3d527702311e547f5702106bcca55bfbd [file] [log] [blame]
page.title=Trình ti
parent.title=Hot động
parent.link=activities.html
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>Trong tài liu này</h2>
<ol>
<li><a href="#summary">Tng quan v API Trình ti</a></li>
<li><a href="#app">S dng các Trình ti trong mt ng dng</a>
<ol>
<li><a href="#requirements"></a></li>
<li><a href="#starting">Khi động mt Trình ti</a></li>
<li><a href="#restarting">Khi động li mt Trình ti</a></li>
<li><a href="#callback">S dng các Phương pháp Gi li LoaderManager</a></li>
</ol>
</li>
<li><a href="#example">Ví dụ</a>
<ol>
<li><a href="#more_examples">Thêm Ví dụ</a></li>
</ol>
</li>
</ol>
<h2>Lp khóa</h2>
<ol>
<li>{@link android.app.LoaderManager}</li>
<li>{@link android.content.Loader}</li>
</ol>
<h2>Các mu liên quan</h2>
<ol>
<li> <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.html">
LoaderCursor</a></li>
<li> <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html">
LoaderThrottle</a></li>
</ol>
</div>
</div>
<p>Được gii thiu trong Android 3.0, trình ti giúp vic ti d liu không đồng b
trong mt hot động hoc phân đon tr nên d dàng. Trình ti có nhng đặc đim sau:</p>
<ul>
<li>Chúng sn có cho mi {@link android.app.Activity} và {@link
android.app.Fragment}.</li>
<li>Chúng cung cp kh năng ti d liu không đồng bộ.</li>
<li>Chúng theo dõi ngun d liu ca mình và chuyn giao kết qu mi khi ni dung
thay đổi.</li>
<li>Chúng t động kết ni li vi con chy ca trình ti cui cùng khi được
to li sau khi cu hình thay đổi. Vì thế, chúng không cn truy vn li d liu
ca mình.</li>
</ul>
<h2 id="summary">Tng quan v API Trình ti</h2>
<p>Có nhiu lp và giao din có th có liên quan trong khi s dng
các trình ti trong mt ng dng. Chúng được tóm tt trong bng này.</p>
<table>
<tr>
<th>Lp/Giao din</th>
<th>Mô tả</th>
</tr>
<tr>
<td>{@link android.app.LoaderManager}</td>
<td>Mt lp tóm tt được liên kết vi {@link android.app.Activity} hoc
{@link android.app.Fragment} để qun lý mt hoc nhiu thc th {@link
android.content.Loader}. Nó giúp ng dng qun lý
các thao tác chy lâu hơn cùng vi vòng đời {@link android.app.Activity}
hoc {@link android.app.Fragment}; công dng ph biến nht ca lp này là khi dùng vi
{@link android.content.CursorLoader}, tuy nhiên, các ng dng được t do ghi
trình ti ca chính mình để ti các kiu d liu khác.
<br />
<br />
Ch có mt {@link android.app.LoaderManager} trên mi hot động hoc phân đon. Nhưng mt {@link android.app.LoaderManager} có th có
nhiu trình ti.</td>
</tr>
<tr>
<td>{@link android.app.LoaderManager.LoaderCallbacks}</td>
<td>Mt giao din gi li để mt máy khách tương tác vi {@link
android.app.LoaderManager}. Ví dụ, bn s dng phương pháp gi li {@link
android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()}
để to mt trình ti mi.</td>
</tr>
<tr>
<td>{@link android.content.Loader}</td>
<td>Mt lp tóm tt có vai trò thc hin vic ti d liu không đồng bộ. Đây là
lp cơ bn cho mt trình ti. Thông thường, bn s s dng {@link
android.content.CursorLoader}, nhưng bn có th trin khai lp con ca chính mình. Trong khi
các trình ti đang hot động, chúng s theo dõi ngun d liu ca mình và chuyn giao
kết qu mi khi ni dung thay đổi. </td>
</tr>
<tr>
<td>{@link android.content.AsyncTaskLoader}</td>
<td>Trình ti tóm tt có chc năng cung cp {@link android.os.AsyncTask} để thc hin công vic.</td>
</tr>
<tr>
<td>{@link android.content.CursorLoader}</td>
<td>Mt lp con ca {@link android.content.AsyncTaskLoader} có chc năng truy vn
{@link android.content.ContentResolver} và tr v mt {@link
android.database.Cursor}. Lp này trin khai giao thc {@link
android.content.Loader} theo mt cách chun hóa để truy vn các con chy,
xây dng trên {@link android.content.AsyncTaskLoader} để thc hin truy vn con chy
trên mt lung nn sao cho nó không chn UI ca ng dng. S dng
trình ti này là cách tt nht để ti d liu không đồng b t mt {@link
android.content.ContentProvider}, thay vì phi thc hin mt truy vn được qun lý thông qua
phân đon hoc các API ca hot động.</td>
</tr>
</table>
<p>Các lp và giao din trong bng trên là nhng thành phn thiết yếu
mà bn s s dng để trin khai mt trình ti trong ng dng ca mình. Bn s không cn tt c chúng
cho tng trình ti mà bn to lp, nhưng bn s luôn cn mt tham chiếu ti {@link
android.app.LoaderManager} để khi to mt trình ti và trin khai
mt lp {@link android.content.Loader} chng hn như {@link
android.content.CursorLoader}. Các phn sau đây trình bày vi bn cách s dng nhng
lp và giao din này trong mt ng dng.</p>
<h2 id ="app">S dng các Trình ti trong mt ng dng</h2>
<p>Phn này mô t cách s dng các trình ti trong mt ng dng Android. Mt
ng dng s dng trình ti thường bao gm:</p>
<ul>
<li>Mt {@link android.app.Activity} hoc {@link android.app.Fragment}.</li>
<li>Mt thc th ca {@link android.app.LoaderManager}.</li>
<li>Mt {@link android.content.CursorLoader} để ti d liu được d phòng bi mt {@link
android.content.ContentProvider}. Hoc cách khác, bn có th trin khai lp con
ca {@link android.content.Loader} hoc {@link android.content.AsyncTaskLoader} ca chính mình để ti
d liu t mt s ngun khác.</li>
<li>Mt trin khai cho {@link android.app.LoaderManager.LoaderCallbacks}.
Đây là nơi bn to trình ti mi và qun lý các tham chiếu ca mình ti các
trình ti hin có.</li>
<li>Mt cách để hin th d liu ca trình ti, chng hn như {@link
android.widget.SimpleCursorAdapter}.</li>
<li>Mt ngun d liu, chng hn như mt {@link android.content.ContentProvider}, khi s dng mt
{@link android.content.CursorLoader}.</li>
</ul>
<h3 id="starting">Khi động mt Trình ti</h3>
<p>{@link android.app.LoaderManager} qun lý mt hoc nhiu thc th {@link
android.content.Loader} trong mt {@link android.app.Activity} hoc
{@link android.app.Fragment}. Ch có mt {@link
android.app.LoaderManager} trên mi hot động hoc phân đon.</p>
<p>Thông thường, bn
s khi to mt {@link android.content.Loader} bên trong phương pháp {@link
android.app.Activity#onCreate onCreate()} của hoạt động, hoặc trong phương pháp
{@link android.app.Fragment#onActivityCreated onActivityCreated()} của phân đoạn. Bạn
làm điu này như sau:</p>
<pre>// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
getLoaderManager().initLoader(0, null, this);</pre>
<p>Phương pháp {@link android.app.LoaderManager#initLoader initLoader()} sẽ lấy những
tham s sau:</p>
<ul>
<li>Mt ID duy nht xác định trình ti. Trong ví d này, ID là 0.</li>
<li>Các tham đối tùy chn để cung cp cho trình ti khi
xây dng (<code>null</code> trong ví dụ này).</li>
<li>Trin khai {@link android.app.LoaderManager.LoaderCallbacks}, phương pháp mà
{@link android.app.LoaderManager} gi để báo cáo các s kin trình ti. Trong ví d này
, lp cục bộ trin khai giao din {@link
android.app.LoaderManager.LoaderCallbacks}, vì thế nó chuyn mt tham chiếu
ti chính nó, {@code this}.</li>
</ul>
<p>Lnh gi {@link android.app.LoaderManager#initLoader initLoader()} đảm bảo rằng một trình tải
được khi to và hin hot. Nó có hai kết qu có th xy ra:</p>
<ul>
<li>Nếu trình ti được quy định bi ID đã tn ti, trình ti được to lp cui cùng
s được s dng li.</li>
<li>Nếu trình ti được quy định bi ID <em>không</em> tn ti,
{@link android.app.LoaderManager#initLoader initLoader()} sẽ kích khởi phương pháp
{@link android.app.LoaderManager.LoaderCallbacks}{@link android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()}.
Đây là nơi bn trin khai mã để khi to và tr v mt trình ti mi.
Để bàn thêm, hãy xem phn <a href="#onCreateLoader">onCreateLoader</a>.</li>
</ul>
<p>Dù trong trường hp nào, trin khai {@link android.app.LoaderManager.LoaderCallbacks}
đã cho được liên kết vi trình ti, và s được gi khi
trng thái ca trình ti thay đổi. Nếu ti đim thc hin lnh gi này, hàm gi đang trong trng thái
được khi động ca nó, và trình ti được yêu cu đã tn ti và đã khi to
d liu ca nó, khi đó h thng s gi {@link
android.app.LoaderManager.LoaderCallbacks#onLoadFinished onLoadFinished()}
ngay lp tc (trong khi {@link android.app.LoaderManager#initLoader initLoader()}),
vì thế bn phi sn sàng khi điu này xy ra. Xem <a href="#onLoadFinished">
onLoadFinished</a> để thảo luận thêm về lệnh gọi lại này</p>
<p>Lưu ý rng phương pháp {@link android.app.LoaderManager#initLoader initLoader()}
s tr v {@link android.content.Loader} đã được to lp, nhưng bn không
cn bt li mt tham chiếu ti nó. {@link android.app.LoaderManager} t động qun lý
vòng đời ca trình ti. {@link android.app.LoaderManager}
khi động và dng ti khi cn và duy trì trng thái ca trình ti
và ni dung đi kèm ca nó. Như hàm ý, bn hiếm khi tương tác trc tiếp vi các trình ti
(thông qua mt ví d v vic s dng các phương pháp trình ti để tinh chnh hành vi
ca mt trình ti, hãy xem ví d <a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html"> LoaderThrottle</a>).
Bn thường s dng nht là các phương pháp {@link
android.app.LoaderManager.LoaderCallbacks} để can thip vào tiến trình ti
khi din ra mt s kin đặc bit. Để tho lun thêm v ch đề này, hãy xem phn <a href="#callback">S dng Phương pháp Gi li LoaderManager</a>.</p>
<h3 id="restarting">Khi động li mt Trình ti</h3>
<p>Khi bn s dng {@link android.app.LoaderManager#initLoader initLoader()}, như
trình bày bên trên, nó s dng mt trình ti hin hu vi ID được quy định nếu có.
Nếu không có, nó s to mt trình ti. Nhưng đôi khi bn mun b d liu cũ ca mình
và bt đầu li.</p>
<p>Để b d liu cũ ca mình, hãy s dng {@link
android.app.LoaderManager#restartLoader restartLoader()}. Ví dụ, việc
trin khai {@link android.widget.SearchView.OnQueryTextListener} này s khi động li
trình ti khi truy vn ca người dùng thay đổi. Trình ti cn được khi động li sao cho
nó có th s dng bộ lc tìm kiếm được điu chnh để thc hin mt truy vn mi:</p>
<pre>
public boolean onQueryTextChanged(String newText) {
// Called when the action bar search text has changed. Update
// the search filter, and restart the loader to do a new query
// with this filter.
mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
getLoaderManager().restartLoader(0, null, this);
return true;
}</pre>
<h3 id="callback">S dng các Phương pháp Gi li LoaderManager</h3>
<p>{@link android.app.LoaderManager.LoaderCallbacks} là mt giao din gi li
cho phép mt máy khách tương tác vi {@link android.app.LoaderManager}. </p>
<p>Các trình ti, đặc bit là {@link android.content.CursorLoader}, được k vng s
gi li d liu ca chúng sau khi b dng. Điu này cho phép ng dng gi li
d liu ca chúng qua hot động hoc các phương pháp {@link android.app.Activity#onStop
onStop()} và {@link android.app.Activity#onStart onStart()} của phân đoạn, sao cho khi
người dùng quay li mt ng dng, h không phi ch d liu
ti li. Bn s dng các phương pháp {@link android.app.LoaderManager.LoaderCallbacks}
khi cn biết khi nào thì nên to mt trình ti mi, và để thông báo vi ng dng khi nào
thì đến lúc để dng s dng d liu ca mt trình ti.</p>
<p>{@link android.app.LoaderManager.LoaderCallbacks} bao gm nhng phương pháp
sau:</p>
<ul>
<li>{@link android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()} —
Khi to và tr v mt {@link android.content.Loader} mi cho ID đã cho.
</li></ul>
<ul>
<li> {@link android.app.LoaderManager.LoaderCallbacks#onLoadFinished onLoadFinished()}
Được gi khi mt trình ti được to trước đó đã hoàn tt vic ti.
</li></ul>
<ul>
<li>{@link android.app.LoaderManager.LoaderCallbacks#onLoaderReset onLoaderReset()}
Được gi khi mt trình ti được to trước đó đang được đặt li, vì thế mà khiến d liu
ca nó không sn có.
</li>
</ul>
<p>Nhng phương pháp này được mô t chi tiết hơn trong các phn sau.</p>
<h4 id ="onCreateLoader">onCreateLoader</h4>
<p>Khi bn định truy cp mt trình ti (ví dụ, thông qua {@link
android.app.LoaderManager#initLoader initLoader()}), nó kiểm tra xem
trình ti được quy định bi ID có tn ti không. Nếu không, nó s kích khi phương pháp {@link
android.app.LoaderManager.LoaderCallbacks} {@link
android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()}. Đây
là lúc bn to mt trình ti mi. Thông thường s có mt {@link
android.content.CursorLoader}, nhưng bn có th trin khai lp con {@link
android.content.Loader} ca chính mình. </p>
<p>Trong ví d này, phương pháp gi li {@link
android.app.LoaderManager.LoaderCallbacks#onCreateLoader onCreateLoader()}
s to mt {@link android.content.CursorLoader}. Bn phi xây dng
{@link android.content.CursorLoader} bng cách s dng phương pháp hàm dng ca nó mà yêu cu
trn b thông tin cn thiết để thc hin mt truy vn ti {@link
android.content.ContentProvider}. C thể, nó cn:</p>
<ul>
<li><em>uri</em> — URI của nội dung cần truy xuất. </li>
<li><em>d tho</em> Mt danh sách các ct s tr về. Vic chuyn
<code>null</code> sẽ trả về tất cả cột, điều này không hiệu quả. </li>
<li><em>la chn</em> Mt b lc khai báo các hàng nào s tr về,
có định dng như mt mnh đề SQL WHERE (không gm chính mnh đề WHERE). Vic chuyn
<code>null</code> sẽ trả về tất cả hàng cho URI đã cho. </li>
<li><em>selectionArgs</em> Bn có th thêm ?s vào la chn,
chúng s được thay thế bng các giá tr t <em>selectionArgs</em>, theo th t xut hin trong
la chn. Giá tr s được gn kết thành các Xâu. </li>
<li><em>sortOrder</em> Cách sp xếp th t các hàng, được định dng như mt mnh đề SQL
ORDER BY (không bao gm chính mnh đề ORDER BY). Vic chuyn <code>null</code> s
s dng th t sp xếp mc định, điu này có th dn đến kết qu không theo th tự.</li>
</ul>
<p>Ví dụ:</p>
<pre>
// If non-null, this is the current filter the user has provided.
String mCurFilter;
...
public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
// This is called when a new Loader needs to be created.  This
// sample only has one Loader, so we don't care about the ID.
// First, pick the base URI to use depending on whether we are
// currently filtering.
Uri baseUri;
    if (mCurFilter != null) {
        baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
                Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = &quot;((&quot; + Contacts.DISPLAY_NAME + &quot; NOTNULL) AND (&quot;
            + Contacts.HAS_PHONE_NUMBER + &quot;=1) AND (&quot;
            + Contacts.DISPLAY_NAME + &quot; != '' ))&quot;;
    return new CursorLoader(getActivity(), baseUri,
            CONTACTS_SUMMARY_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + &quot; COLLATE LOCALIZED ASC&quot;);
}</pre>
<h4 id="onLoadFinished">onLoadFinished</h4>
<p>Phương pháp này được gi khi mt trình ti được to trước đó đã hoàn thành vic ti ca mình.
Phương pháp này được bo đảm s được gi trước khi gii phóng d liu cui cùng
được cung cp cho trình ti này. Ti đim này, bn nên loi b mi trường hp s dng
d liu cũ (do nó s được gii phóng sm), nhưng không nên
t mình gii phóng d liu do trình ti s hu d liu và s đảm nhn vic này.</p>
<p>Trình ti s gii phóng d liu sau khi nó biết ng dng đang không còn
s dng nó na. Ví dụ, nếu d liu là mt con chy t mt {@link
android.content.CursorLoader}, bn không nên t mình gi {@link
android.database.Cursor#close close()} trên dữ liệu đó. Nếu con chạy đang được đặt
trong mt {@link android.widget.CursorAdapter}, bn nên s dng phương pháp {@link
android.widget.SimpleCursorAdapter#swapCursor swapCursor()} sao cho
{@link android.database.Cursor} cũ không b đóng. Ví dụ:</p>
<pre>
// This is the Adapter being used to display the list's data.<br
/>SimpleCursorAdapter mAdapter;
...
public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
// Swap the new cursor in.  (The framework will take care of closing the
// old cursor once we return.)
mAdapter.swapCursor(data);
}</pre>
<h4 id="onLoaderReset">onLoaderReset</h4>
<p>Phương pháp này được gi khi mt trình ti được to trước đó đang được đặt li, vì thế mà khiến
d liu ca nó không sn có. Lnh gi li này cho phép bn tìm hiu xem khi nào thì d liu
s được gii phóng để bn có th loi b tham chiếu ca mình ti nó.  </p>
<p>S trin khai này gi ra
{@link android.widget.SimpleCursorAdapter#swapCursor swapCursor()}
vi mt giá tr <code>null</code>:</p>
<pre>
// This is the Adapter being used to display the list's data.
SimpleCursorAdapter mAdapter;
...
public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
// This is called when the last Cursor provided to onLoadFinished()
// above is about to be closed.  We need to make sure we are no
// longer using it.
mAdapter.swapCursor(null);
}</pre>
<h2 id="example">Ví dụ</h2>
<p>Ly mt ví dụ, sau đây là trin khai đầy đủ ca {@link
android.app.Fragment} có chc năng hin th mt {@link android.widget.ListView} cha
kết qu ca mt truy vn đối vi trình cung cp ni dung danh bạ. Nó s dng mt {@link
android.content.CursorLoader} để qun lý truy vn trên trình cung cp.</p>
<p>Để mt ng dng truy cp danh b ca mt người dùng, như minh ha trong ví d này, bn kê khai
ca nó phi bao gm quyn
{@link android.Manifest.permission#READ_CONTACTS READ_CONTACTS}.</p>
<pre>
public static class CursorLoaderListFragment extends ListFragment
        implements OnQueryTextListener, LoaderManager.LoaderCallbacks&lt;Cursor&gt; {
// This is the Adapter being used to display the list's data.
    SimpleCursorAdapter mAdapter;
    // If non-null, this is the current filter the user has provided.
    String mCurFilter;
    @Override public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        // Give some text to display if there is no data.  In a real
        // application this would come from a resource.
        setEmptyText(&quot;No phone numbers&quot;);
        // We have a menu item to show in action bar.
        setHasOptionsMenu(true);
        // Create an empty adapter we will use to display the loaded data.
        mAdapter = new SimpleCursorAdapter(getActivity(),
                android.R.layout.simple_list_item_2, null,
                new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
                new int[] { android.R.id.text1, android.R.id.text2 }, 0);
        setListAdapter(mAdapter);
        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);
    }
    @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        // Place an action bar item for searching.
        MenuItem item = menu.add(&quot;Search&quot;);
        item.setIcon(android.R.drawable.ic_menu_search);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        SearchView sv = new SearchView(getActivity());
        sv.setOnQueryTextListener(this);
        item.setActionView(sv);
    }
    public boolean onQueryTextChange(String newText) {
        // Called when the action bar search text has changed.  Update
        // the search filter, and restart the loader to do a new query
        // with this filter.
        mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
        getLoaderManager().restartLoader(0, null, this);
        return true;
    }
    @Override public boolean onQueryTextSubmit(String query) {
        // Don't care about this.
        return true;
    }
    @Override public void onListItemClick(ListView l, View v, int position, long id) {
        // Insert desired behavior here.
        Log.i(&quot;FragmentComplexList&quot;, &quot;Item clicked: &quot; + id);
    }
    // These are the Contacts rows that we will retrieve.
    static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
        Contacts._ID,
        Contacts.DISPLAY_NAME,
        Contacts.CONTACT_STATUS,
        Contacts.CONTACT_PRESENCE,
        Contacts.PHOTO_ID,
        Contacts.LOOKUP_KEY,
    };
    public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
        // This is called when a new Loader needs to be created.  This
        // sample only has one Loader, so we don't care about the ID.
        // First, pick the base URI to use depending on whether we are
        // currently filtering.
        Uri baseUri;
        if (mCurFilter != null) {
            baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
                    Uri.encode(mCurFilter));
        } else {
            baseUri = Contacts.CONTENT_URI;
        }
        // Now create and return a CursorLoader that will take care of
        // creating a Cursor for the data being displayed.
        String select = &quot;((&quot; + Contacts.DISPLAY_NAME + &quot; NOTNULL) AND (&quot;
                + Contacts.HAS_PHONE_NUMBER + &quot;=1) AND (&quot;
                + Contacts.DISPLAY_NAME + &quot; != '' ))&quot;;
        return new CursorLoader(getActivity(), baseUri,
                CONTACTS_SUMMARY_PROJECTION, select, null,
                Contacts.DISPLAY_NAME + &quot; COLLATE LOCALIZED ASC&quot;);
    }
    public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
        // Swap the new cursor in.  (The framework will take care of closing the
        // old cursor once we return.)
        mAdapter.swapCursor(data);
    }
    public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
        // This is called when the last Cursor provided to onLoadFinished()
        // above is about to be closed.  We need to make sure we are no
        // longer using it.
        mAdapter.swapCursor(null);
    }
}</pre>
<h3 id="more_examples">Thêm Ví dụ</h3>
<p>Có mt vài mu khác trong <strong>ApiDemos</strong> để
minh ha cách s dng các trình ti:</p>
<ul>
<li><a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.html">
LoaderCursor</a> Mt phiên bn hoàn chnh ca
đon mã HTML trình bày trên.</li>
<li><a href="{@docRoot}resources/samples/ApiDemos/src/com/example/android/apis/app/LoaderThrottle.html"> LoaderThrottle</a> Mt ví d v cách s dng điu chnh để gim
s truy vn mà mt trình cung cp ni dung thc hin khi d liu ca nó thay đổi.</li>
</ul>
<p>Để biết thông tin v vic ti xung và cài đặt các mu SDK, hãy xem phn <a href="http://developer.android.com/resources/samples/get.html"> Ti
Mu</a>. </p>