ListActivity.onDestroy, remove any pending callbacks.

Added a onDestroy method to do the callbacks cleanup.

Apologies for the line end whitespaces my editor removed
automatically.

Bug:2090959
Change-Id: Id3ea4b8fc38e55c1b1ef78b3ec5b81cb02ab5b69
This commit is contained in:
Nicolas Catania
2010-03-12 15:21:50 -08:00
parent 069b3cfcd4
commit f767e75212

View File

@@ -51,31 +51,31 @@ import android.widget.ListView;
* The following code demonstrates an (ugly) custom screen layout. It has a list
* with a green background, and an alternate red "no data" message.
* </p>
*
*
* <pre>
* &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
* &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
* android:orientation=&quot;vertical&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_height=&quot;match_parent&quot;
* android:paddingLeft=&quot;8dp&quot;
* android:paddingRight=&quot;8dp&quot;&gt;
*
*
* &lt;ListView android:id=&quot;@id/android:list&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_height=&quot;match_parent&quot;
* android:background=&quot;#00FF00&quot;
* android:layout_weight=&quot;1&quot;
* android:drawSelectorOnTop=&quot;false&quot;/&gt;
*
*
* &lt;TextView id=&quot;@id/android:empty&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_height=&quot;match_parent&quot;
* android:background=&quot;#FF0000&quot;
* android:text=&quot;No data&quot;/&gt;
* &lt;/LinearLayout&gt;
* </pre>
*
*
* <p>
* <strong>Row Layout</strong>
* </p>
@@ -96,27 +96,27 @@ import android.widget.ListView;
* source for the resource two_line_list_item, which displays two data
* fields,one above the other, for each list row.
* </p>
*
*
* <pre>
* &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
* &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
* android:layout_width=&quot;match_parent&quot;
* android:layout_height=&quot;wrap_content&quot;
* android:orientation=&quot;vertical&quot;&gt;
*
*
* &lt;TextView android:id=&quot;@+id/text1&quot;
* android:textSize=&quot;16sp&quot;
* android:textStyle=&quot;bold&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_height=&quot;wrap_content&quot;/&gt;
*
*
* &lt;TextView android:id=&quot;@+id/text2&quot;
* android:textSize=&quot;16sp&quot;
* android:layout_width=&quot;match_parent&quot;
* android:layout_height=&quot;wrap_content&quot;/&gt;
* &lt;/LinearLayout&gt;
* </pre>
*
*
* <p>
* You must identify the data bound to each TextView object in this layout. The
* syntax for this is discussed in the next section.
@@ -137,40 +137,40 @@ import android.widget.ListView;
* Contacts provider for all contacts, then binding the Name and Company fields
* to a two line row layout in the activity's ListView.
* </p>
*
*
* <pre>
* public class MyListAdapter extends ListActivity {
*
*
* &#064;Override
* protected void onCreate(Bundle savedInstanceState){
* super.onCreate(savedInstanceState);
*
*
* // We'll define a custom screen layout here (the one shown above), but
* // typically, you could just use the standard ListActivity layout.
* setContentView(R.layout.custom_list_activity_view);
*
*
* // Query for all people contacts using the {@link android.provider.Contacts.People} convenience class.
* // Put a managed wrapper around the retrieved cursor so we don't have to worry about
* // requerying or closing it as the activity changes state.
* mCursor = this.getContentResolver().query(People.CONTENT_URI, null, null, null, null);
* startManagingCursor(mCursor);
*
* // Now create a new list adapter bound to the cursor.
*
* // Now create a new list adapter bound to the cursor.
* // SimpleListAdapter is designed for binding to a Cursor.
* ListAdapter adapter = new SimpleCursorAdapter(
* this, // Context.
* android.R.layout.two_line_list_item, // Specify the row template to use (here, two columns bound to the two retrieved cursor
* android.R.layout.two_line_list_item, // Specify the row template to use (here, two columns bound to the two retrieved cursor
* rows).
* mCursor, // Pass in the cursor to bind to.
* new String[] {People.NAME, People.COMPANY}, // Array of cursor columns to bind to.
* new int[] {android.R.id.text1, android.R.id.text2}); // Parallel array of which template objects to bind to those columns.
*
*
* // Bind to our new adapter.
* setListAdapter(adapter);
* }
* }
* </pre>
*
*
* @see #setListAdapter
* @see android.widget.ListView
*/
@@ -194,13 +194,13 @@ public class ListActivity extends Activity {
mList.focusableViewAvailable(mList);
}
};
/**
* This method will be called when an item in the list is selected.
* Subclasses should override. Subclasses can call
* getListView().getItemAtPosition(position) if they need to access the
* data associated with the selected item.
*
*
* @param l The ListView where the click happened
* @param v The view that was clicked within the ListView
* @param position The position of the view in the list
@@ -208,11 +208,11 @@ public class ListActivity extends Activity {
*/
protected void onListItemClick(ListView l, View v, int position, long id) {
}
/**
* Ensures the list view has been created before Activity restores all
* of the view states.
*
*
*@see Activity#onRestoreInstanceState(Bundle)
*/
@Override
@@ -221,10 +221,19 @@ public class ListActivity extends Activity {
super.onRestoreInstanceState(state);
}
/**
* @see Activity#onDestroy()
*/
@Override
protected void onDestroy() {
mHandler.removeCallbacks(mRequestFocus);
super.onDestroy();
}
/**
* Updates the screen state (current list and other views) when the
* content changes.
*
*
* @see Activity#onContentChanged()
*/
@Override
@@ -262,7 +271,7 @@ public class ListActivity extends Activity {
/**
* Set the currently selected list item to the specified
* position with the adapter's data
*
*
* @param position
*/
public void setSelection(int position) {
@@ -290,7 +299,7 @@ public class ListActivity extends Activity {
ensureList();
return mList;
}
/**
* Get the ListAdapter associated with this activity's ListView.
*/
@@ -303,7 +312,7 @@ public class ListActivity extends Activity {
return;
}
setContentView(com.android.internal.R.layout.list_content);
}
private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
@@ -313,4 +322,3 @@ public class ListActivity extends Activity {
}
};
}