@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_content); final int id = getIntent().getExtras().getInt("_ID"); String sql = "SELECT c.* from related r " + "LEFT JOIN content c on c.content_id = r.content_id " + "WHERE c.type = 'disease' AND r._id = " + id; DoctorMeDatabase mOpenHelper = new DoctorMeDatabase(this); final SQLiteDatabase db = mOpenHelper.getReadableDatabase(); mCursor = db.rawQuery(sql, null); mAdapter = new NormalItemAdapter(this); mAdapter.changeCursor(mCursor); setListAdapter(mAdapter); TextView empty = (TextView) getListView().getEmptyView(); empty.setText("Empty"); registerForContextMenu(getListView()); listActivityHelper = new ListActivityHelper(this, mAdapter); }
@Override protected void onListItemClick(ListView listView, View view, int position, long id) { final Cursor c = (Cursor) mAdapter.getItem(position); final String contentId = c.getString(c.getColumnIndex(DoctorMeContract.Contents.CONTENT_ID)); final Uri itemUri = DoctorMeContract.Contents.Diseases.buildItemUri(contentId); final Intent intent = new Intent(Intent.ACTION_VIEW, itemUri); Log.d(TAG, "Click on item: " + contentId + ", URI: " + itemUri); startActivity(intent); Toast.makeText(this, "Click on item: " + contentId + ", URI: " + itemUri, Toast.LENGTH_SHORT) .show(); }