/** * Get the row id associated with the specified position in the list. * If there is an exception, safely abandon the cursor * * @param position The position of the item within the adapter's data set whose row id we want. * @return The id of the item at the specified position. */ @Override public long getItemId(int position) { try { return super.getItemId(position); } catch (Exception e) { this.swapCursor(null); return 0; } }
/** * Stores the path of selected form and finishes. */ @Override protected void onListItemClick(ListView listView, View view, int position, long id) { // get uri to form long idFormsTable = ((SimpleCursorAdapter) getListAdapter()).getItemId(position); Uri formUri = ContentUris.withAppendedId(FormsColumns.CONTENT_URI, idFormsTable); Collect.getInstance().getActivityLogger().logAction(this, "onListItemClick", formUri.toString()); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action)) { // caller is waiting on a picked form setResult(RESULT_OK, new Intent().setData(formUri)); } else { // caller wants to view/edit a form, so launch formentryactivity startActivity(new Intent(Intent.ACTION_EDIT, formUri)); } finish(); }