• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to create one Android activity with several views?

subone

Lurker
Hello,

I am using Eclipse and I am creating an application.
I have a Listview that has a list of items in the main activity.
And I have another activity called (for example): items.

What I want to do:

If I click on Item1 in Main activity, it opens the "items" activity and shows ITEM 1 text, and if I click on Item2 in Main activity, it opens the "items" activity and shows ITEM 2 text.
I am asking because maybe I will have many items in the listview, and I don't want to create a new activity for each item.

How can this be made?

Thanks.
 
Hi
You need to implement ListView.setOnItemClickListeners in the main activity
In there you create an Intent object and assign to it the Items activity and the index of the item you clicked then call startActivity with the intent you created.


For info there is a cool website that gathers the best IT videos of YouTube.
It's called www.QualTekVideo.com check the Android section. It's full of great video tutorials
 
Back
Top Bottom