Pass custom list item content to new activity when list item is clicked from a listview?

Lv. SetOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView arg0, View arg1, int position, long arg3){ Object o=lv. GetItemAtPosition(position); UtilityClass u=(UtilityClass)o; String s=u.getMyData(); Intent edit = new Intent(context, AnotherActivity.

Class); edit. PutExtra("your_identifier", Integer. ToString(position)); startActivity(intent); }}).

Great, I have the following code already. I am stuck at the Object o part. When I run the debugger I can see all the values that the object holds.

One of the values is the one I want. I tried the UtilityClass way like this, but I am getting errors when adding the UtilitClass type variable. It doesn't seem to exist in Java.Do I have to create the class myself?

Please let me know. Thank You very much. – skoko Mar 22 at 18:03 Yes you have to create class yourselves.

This class contains getter and setter methods for list items. You Can see custom adapter here in the link – Kartik Mar 23 at 4:25.

If you have implemented onItemClickListner / onItemSelectListner then you can get a callback onItemClicked()/ onItemSelected() from there using the Adapter get the item from selected position. And the same can be sent to another activity using a bundle/extra.

Ok, I have that method. My main problem is that I cannot see what is inside the listview item once the item is clicked. I know the position of the item.

The item also has 4 textviews inside of it. When I call something like String test = (String)((Cursor)parent. GetItemByPosition(position)).

GetString(int n) I am not able to get anything out of it. This is getting so frustrating. – skoko Mar 22 at 7:12 in that case its better to maintain the data inside the adapter and that can be referred.

Add all the item in one data structure and get the selected item from there instead of getting it from the view. – Atmaram Mar 22 at 8:09.

Essentially I have a listview that is being populated programatically with a custom list item view and a custom adapter. This works like a charm but the problem is that I have to sort this list in a specific way once it is populated. The values that are being put into the list are stored in String arrays.

The problem is that when I sort the listview it changes the index of where I thought the values would be stored. I want to start a new activity with certain values found in the list view. Is this possible?

I could take a string from the list item and can look it up in my arrays storing the values when that item is clicked. I can then start a new intent with extras so that I can pass this new data to the new activity. So, is it possible to extract a string from a list item?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions