Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7916537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:50:45+00:00 2026-06-03T14:50:45+00:00

I am a beginner programmer so please bear with me. I am trying to

  • 0

I am a beginner programmer so please bear with me. I am trying to create an app where the item in the list view affects what will be displayed in the next activity. So far, I have the list activity:

public class Primary extends ListActivity{
private static final String[] items = {"Item1", "Item2", "Item3", "item4", "Item5"};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));

    TextView heading =(TextView)findViewById(R.id.listViewHeading);
    heading.setText("Primary");
}

public void onListItemClick(ListView parent, View v, int position, long id){

}

and for the second activity, I have this:

public class ImageActivity extends Activity{
TextView heading;
ImageView image;
TextView text;
    public static final String[] headings={"heading 1", "heading 2", "heading 3", "heading 4", "heading 5",};


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_activity);

    heading = (TextView)findViewById(R.id.adHeading);
    image = (ImageView)findViewById(R.id.adImage);
    text =(TextView)findViewById(R.id.adText);

    addInfo();
}

private void addInfo() {
    heading.setText(headings[x]);
    image.setImageResource(images[x]);
    text.setText(text[x]);

}

How can i make it so that the heading, image, and text change based on what item in the list view was selected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:50:46+00:00Added an answer on June 3, 2026 at 2:50 pm

    I think u want to set the heading, image and text in second activity, related to first activity’s selected index in list.

    just do 1 thing, put following code in 1st activity

        public void onListItemClick(ListView parent, View v, int position, long id)
        {
            Intent intent = new Intent(this.getApplicationContext(), ImageActivity.class);
            intent.putExtra("pos", position);
            startActivity(intent);
        }
    

    so, now u r passing the position of item selected in list.

    now, put following code in next activity

        private void addInfo()
        {
            Bundle ext = getIntent().getExtras();
            if(ext != null)
            {
                int pos= ext.getInteger("pos");
                           //  ext.getInt("pos");
    
                heading.setText(headings[pos]);
    
                //  hey, frend, you don't have any array for selecting image-name and text
                //  image.setImageResource(images[x]);
                //  text.setText(text[x]);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a beginner programmer so please bear with me. This app runs fine but
I'm a beginner level programmer trying to make a game app for the iphone
I am a beginner directshow programmer I am trying to make WPF App that
Beginner programmer here....hope it makes sense :) I have created a console app that
I'm a beginner programmer, and I'm learning to program a web app using WampServer.
One friend of mine is beginner programmer and he is trying to learn classic
i'm a beginner programmer and i'm currently working on a basic navigation app. I
Beginner programmer here. So bear with me. I have a simple python program. print
This is not homework. I am a beginner (novice) java programmer, trying to read
I'm a young (highschool next year) beginner programmer, currently learning Python and starting to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.