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

  • SEARCH
  • Home
  • 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 6100069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:20:39+00:00 2026-05-23T13:20:39+00:00

Activity that is sending the putExtra() @Override protected void onListItemClick(ListView l, View v, int

  • 0

Activity that is sending the putExtra()

@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
    super.onListItemClick(l, v, position, id);
    final Intent intent = new Intent();
    // Set up different intents based on the item clicked: 
    switch (position)
    {
        case ACTIVITY_0:
            intent.putExtra("Value1", "Display this text!");
            intent.setClass(this, com.a.someclass.class);
}
    startActivityForResult(intent, position);
}

Activity receiving the putExtra()

@Override
protected void onCreate(Bundle bundle) {
    // TODO Auto-generated method stub
    super.onCreate(bundle);
    setContentView(R.layout.information);
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        return;
    }
    String value1 = extras.getString("Value1");

    if (value1 != null) {
        informationTitle = (TextView)findViewById(R.id.informationTitle);
        informationText = (WebView)findViewById(R.id.informationText);
        informationTitle.setText(value1);
    }

Original Message:

i have been searching everywhere for a good tutorial on this, i have posted my code online so people can look at it but have not found the help i needed.

I am new to this and what i am basically trying to do is just have a list of items which are all linked to one class that has a dynamic TextView that will be used for the title and a WebView for content, And so basically when a item is clicked on the list it will open up the new activity/intent and it will also pass arguments to change the TextView and WebView accordingly.

I know how to open a new activity by making a new class for each item on the list but i am pretty sure there is an easier way where i can reuse one class and just keep changing the TextView and WebView. The reason i say this is because i have 15 items on my list, but that will expand overtime so i dont want to be making 50-60 different classes to open up each new item.

If some could point me to the right tutorial or give me some insight on here i will really really appreciate it!

Thank you

  • 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-05-23T13:20:39+00:00Added an answer on May 23, 2026 at 1:20 pm

    To accomplish that, you would, instead of using a different Intent for each list item, call the same Activity with the same Intent, but pass extras along with it.

    Let’s say, for instance, that you want to pass a different String depending on which list item is clicked. You would want to

    myIntent.putExtra(String key, String value);
    startActivity(myIntent);
    

    The Activity that you start with this Intent will then be able to grab these extras in its onCreate() using

    Bundle extras = getIntent().getExtras();
    

    and access the extras you put in the Intent using the methods outlined here. This way you can use a single Activity for all list items but have the Activity display different information based on the extra values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity that when users press share on a file it would
I am making an activity that will edit the shared preferences just when the
I have created an Activity that will behave like a popup menu is actually
I have an Activity that should only get created once. That is, onCreate can
Whenever the activity that initiates the scan happens, the android application force closes. It
I have an activity that shows some TextView s and EditText s, as well
I have an activity that some times OutOfMemory exception occurs in some parts of
I have an activity that I'd like to load from a preference screen. I'm
I have an activity that opens txt files. And everytime a user wants to
I am using an Activity that extends SherlockFragmentActivity , that has 3 tabs. The

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.