• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i make every item on my list view of a new activity

 
johnson dubula
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good day guy

how do i make every item on my list view of a new activity
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
johnson dubula wrote:good day guy

how do i make every item on my list view of a new activity

Please ask the question again. I do not understand what you are asking.
 
Giovanni Montano
Ranch Hand
Posts: 246
4
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Johnson, do you mean you do not see the Listview into your activity? could you post your activity_main.xml also?
 
johnson dubula
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean how do i make every item on the list open a new activity and have a different colour
 
Tim Moores
Bartender
Posts: 3128
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The former can be achieved by setting an AdapterView.OnItemClickListener for the ListView, and inside the listener firing intents that start the appropriate activities.

The latter would be done by creating your own adapter class that extends the getView method of ArrayAdapter, and in getView alter the list items as desired.
 
johnson dubula
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know that i have to use the AdapterView.OnItemClickListener and the intent fuction,i just dnt know how to specify the the item on the list
 
Tim Moores
Bartender
Posts: 3128
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to specify the the item on the list

The position in the list is passed to the onItemClicked method as the "position" parameter.
 
Giovanni Montano
Ranch Hand
Posts: 246
4
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:
how to specify the the item on the list

The position in the list is passed to the onItemClicked method as the "position" parameter.

it is one of the easiest things you can do in Android, if you search android button listview on the internet you can find a lot of code templates, to work this out.

making then a custom adapter( listview different colors) is something can be not trivial for you at this stage, I would stick a bit more on the basis, going trough the android developers training sessions on the official documentation, and also some java core, otherwise you could not grasp the use of inner classes eventually used into the listener, and also how to use the debug.
good luck
 
johnson dubula
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you everyone
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic