1

I'm trying to create a screen where I'll have a list of song names( saved as text view). Beside each name I would like to add 2 buttons (favourites and basket).

I'd like to have these buttons be in some way link to the specific song name, that when I click a favourites button beside the song- this song title will be added to next activity --> Favourites. And whenever I click on basket beside the song name - the song title will be added to my shopping list.

I hope it make sense.

Can you let me know what will be the best to do it? Or even if it is possible.... Thanks.

Alfie
  • 53
  • 1
  • 8

1 Answers1

0

This is definitely possible and a fairly common pattern in Android. What you need to do is create a ListView and set an instance of your custom adapter to it. In the adapter, you need to at least override the getView method to specify the contents of each item in your list. This is where you can add the two buttons two your item and set their onclick listener (possibly the adapter). You can use setTag to associate instances of the button with the item data.

Here is a similar question: Android: ListView elements with multiple clickable buttons

Community
  • 1
  • 1
battery
  • 502
  • 6
  • 26