-1

I have a ListView with my sqlite data and i would like to click and display the value in another Activity.

Can anyone teach me how to do this?

Below is my code:

Cursor cursor = mydb.queueAll();
    startManagingCursor(cursor);

    String[] from = new String[] { myDbAdapter.ELDERLY_DATE_TIME };
    int[] to = new int[] { R.id.textView1 };

    SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this,
            R.layout.displayactivity, cursor, from, to);
    listContent.setAdapter(cursorAdapter);
    mydb.close();

    listContent.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // TODO Auto-generated method stub

        }

    });

Thanks in advance :)

prolink007
  • 33,872
  • 24
  • 117
  • 185
daek
  • 13
  • 5
  • Where do you want to display the information? In another Activity, a popup window, a Toast, etc? **Also** exactly what information do you want to display? – Sam Aug 02 '12 at 17:58
  • http://mobile.dzone.com/news/listview-data-sqlitedatabase – ahodder Aug 02 '12 at 17:58
  • actually i just want to get the value so that i can past the value to another activity through intent – daek Aug 02 '12 at 18:00
  • Why do you have another `Activity` for showing the value chosen? – prolink007 Aug 02 '12 at 18:14

1 Answers1

0

actually i just want to get the value so that i can past the value to another activity through intent

You do not have to "pass" the value to another Activity. Inside your other Activity you just query for the correct value that was selected in your ListView.

prolink007
  • 33,872
  • 24
  • 117
  • 185
  • actually i going to use the value to get other information from sqlite database and display it on the activity – daek Aug 02 '12 at 18:16
  • You need to pass some identification to the other `Activity` that identifies which item in the `ListView` was selected, with `Intents`. And then the other `Activity` would query the `sqlite` table for the value. But if you could explain why you need to pass this to another `Intent`, there might be a better way to do this in general. – prolink007 Aug 02 '12 at 18:18
  • how am i able to do it? cuase im new to this.. right now i have list view populate data from sqlite – daek Aug 02 '12 at 18:19
  • Here are a couple references that talk about passing data to another `Activity` with `Intents`: http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android http://stackoverflow.com/questions/2736389/how-to-pass-object-from-one-activity-to-another-in-android – prolink007 Aug 02 '12 at 18:24
  • i know how to pass value through intent. But i not too sure how to get value from my listview. – daek Aug 02 '12 at 18:31
  • `onClickListener` gives you a `position` of the `View` that was pressed. This is the item selected. Use that `position` to determine what item was pressed in your `Adapter` and then use that to determine the id you need to use in the other `Activity` to get it from the database. – prolink007 Aug 02 '12 at 18:35