1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to create one Android activity with several views?

Discussion in 'Android Development' started by subone, Nov 4, 2014.

  1. subone

    subone Lurker
    Thread Starter

    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.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. zsalloum

    zsalloum Newbie

    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
     
Loading...
Similar Threads - create Android activity
  1. My project
    Replies:
    9
    Views:
    750
  2. tiho_bg
    Replies:
    1
    Views:
    4,904
  3. CCCKP
    Replies:
    0
    Views:
    1,457
  4. Anmol hira
    Replies:
    0
    Views:
    1,785
  5. xpressive
    Replies:
    0
    Views:
    1,905
  6. Nabeel Rajabali
    Replies:
    0
    Views:
    1,864
  7. Youssef Hammad
    Replies:
    0
    Views:
    3,220
  8. Chen Dol Dawd
    Replies:
    1
    Views:
    1,185
  9. chethan1703
    Replies:
    0
    Views:
    2,235
  10. Dan Coleman
    Replies:
    0
    Views:
    2,257

Share This Page

Loading...