Using java Syntax Highlighting
- public class selection extends ListActivity {
- private ListAdapter adapter;
- private Cursor managedCursor;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.selection);
- Cursor managedCursor = getContentResolver().query(People.CONTENT_URI, null, null, null, People.NAME + " ASC");
- startManagingCursor(managedCursor);
- String[] columns = new String[]{People.NAME};
- int[] to = new int[] { android.R.id.text1 };
- adapter = new SimpleCursorAdapter(
- this, /* Context. */
- android.R.layout.simple_list_item_1, /* row layout file */
- managedCursor, /* Pass in the cursor to bind to. */
- columns, /* Array of cursor columns to bind to. */
- to); /* Parallel array of which template objects to bind to those columns. */
- /* Bind to new adapter. */
- this.setListAdapter(adapter);
- }
- @Override
- /* Upon clicking a selection, sends the _ID to the "send" screen for retrieving contact data. */
- protected void onListItemClick(ListView l, View v, int position, long id) {
- super.onListItemClick(l, v, position, id);
- Cursor c = managedCursor;
- c.moveToPosition(position);
- Intent i2 = new Intent(this, sendscreen.class);
- i2.putExtra(sendscreen.iD, id);
- startActivity(i2);
- }
- }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
The crash is happening during the click event, specifically at this line according to the debugger:
- Code: Select all
c.moveToPosition(position);
I can't figure out why this is happening. Any help is greatly appreciated!

