DataListpublic class DataList extends android.app.ListActivity
Fields Summary |
---|
MenuItem.OnMenuItemClickListener | mRequery | private String | mDisplay | private android.database.Cursor | mCursor |
Methods Summary |
---|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
Intent intent = getIntent();
mCursor = getContentResolver().query(intent.getData(), null, null, null, null);
mDisplay = intent.getStringExtra("display");
if (mDisplay == null) {
mDisplay = "_id";
}
if (mCursor != null) {
setListAdapter(new SimpleCursorAdapter(
this,
R.layout.url_list,
mCursor,
new String[] {mDisplay},
new int[] {android.R.id.text1}));
}
| public boolean | onCreateOptionsMenu(android.view.Menu menu)
super.onCreateOptionsMenu(menu);
menu.add(0, 0, 0, "Requery").setOnMenuItemClickListener(mRequery);
return true;
| protected void | onListItemClick(android.widget.ListView l, android.view.View v, int position, long id)
mCursor.moveToPosition(position);
ArrayList<ColumnData> data = new ArrayList<ColumnData>();
String[] columnNames = mCursor.getColumnNames();
for (int i=0; i<columnNames.length; i++) {
String str = mCursor.getString(i);
ColumnData cd = new ColumnData(columnNames[i], str);
data.add(cd);
}
Uri uri = null;
int idCol = mCursor.getColumnIndex("_id");
if (idCol >= 0) {
uri = Uri.withAppendedPath(getIntent().getData(), mCursor.getString(idCol));
}
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setClass(this, Details.class);
intent.putExtra("data", data);
int displayColumn = mCursor.getColumnIndex(mDisplay);
if (displayColumn >= 0) {
intent.putExtra("title",
((ColumnData)data.get(displayColumn)).value);
}
startActivity(intent);
| public void | onResume()
super.onResume();
if (mCursor != null) {
mCursor.requery();
}
setTitle("Showing " + mDisplay);
| public void | onStop()
super.onStop();
if (mCursor != null) {
mCursor.deactivate();
}
|
|