20 messages in com.googlegroups.android-beginners[android-beginners] Re: getting item ...| From | Sent On | Attachments |
|---|---|---|
| Sylvester Steele | 21 Jun 2008 07:22 | |
| Mark Murphy | 21 Jun 2008 09:23 | |
| Sylvester Steele | 21 Jun 2008 20:48 | |
| Sylvester Steele | 21 Jun 2008 20:56 | |
| Mark Murphy | 22 Jun 2008 05:00 | |
| Sylvester Steele | 22 Jun 2008 23:09 | |
| Sylvester Steele | 26 Jun 2008 02:23 | |
| Romain Guy | 26 Jun 2008 02:31 | |
| Sylvester Steele | 26 Jun 2008 08:51 | |
| Romain Guy | 26 Jun 2008 08:59 | |
| Fräntz Miccoli | 26 Jun 2008 09:00 | |
| Sylvester Steele | 26 Jun 2008 23:06 | |
| Romain Guy | 26 Jun 2008 23:34 | |
| Sylvester Steele | 27 Jun 2008 11:10 | |
| Romain Guy | 27 Jun 2008 11:18 | |
| jan....@gmail.com | 27 Jun 2008 11:19 | |
| Mark Murphy | 27 Jun 2008 11:33 | |
| Romain Guy | 27 Jun 2008 11:46 | |
| Mark Murphy | 27 Jun 2008 11:52 | |
| Sylvester Steele | 29 Jun 2008 02:55 |
| Subject: | [android-beginners] Re: getting item name from listview.![]() |
|---|---|
| From: | Romain Guy (roma...@google.com) |
| Date: | 06/26/2008 02:31:25 AM |
| List: | com.googlegroups.android-beginners |
Somewhere, you must have created an Adapter and set it on the ListView. In your onItemClick() method, there's a parameter called position. It gives you the index of the clicked item in the adapter. You just need to call myAdapter.getItem(position) and you will get the result you want.
On Thu, Jun 26, 2008 at 2:24 AM, Sylvester Steele <sylv...@gmail.com> wrote:
I am still stuck here, someone please help!
Sylvester
On Jun 23, 11:09 am, Sylvester Steele <sylv...@gmail.com> wrote:
Actually, they both return a View. You need to cast the View to the type
you created as your entries (e.g., TextView), then get the data out of there (e.g., getText().toString()). If you're relying on the adapter's built-in row types, they'll be TextView instances.
Yes, I did do that, it shows some weird string, not the stuff I want. Here's some code:
public void onItemClick(AdapterView arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub
new AlertDialog.Builder(activity) .setTitle("Fruit" ) .setMessage("Is" + **[FRUITNAME]**+" your favourite") .setPositiveButton ("Yes", yesListener) .setNegativeButton("No", noListener) .show();
This alert is shown after the user picks a fruit out of a ListView, by clicking on it. Now, I want to show **[FRUITNAME]** , for which I need to know the name of the clicked-fruit. I read these fruits in through a cursor and a SimpleAdapter. I need to know how to get the name of the clicked fruit from the listView.
Thanks. Sylvester
-- Romain Guy www.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to andr...@googlegroups.com To unsubscribe from this group, send email to andr...@googlegroups.com Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---




