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 7030419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:40:06+00:00 2026-05-28T00:40:06+00:00

For example, i have 3 activities.. I also use Tab host with separate activity

  • 0

For example, i have 3 activities.. I also use Tab host with separate activity when switch tab widget.

1) FoodTypeListActivity.class:there is a list of food type i.e. Breakfast, Dinner, Lunch..

2) MainTabActivity.class : Tabhost which has 3 tab widget

3) FoodListActivity.class : this activity is one of tab widget

I have a headlabel in layout of MainTabActivity.class which will show type of food as Textview from the previous activity(FoodTypeListActivity.class)

The problem is; i want to send the name of type of food from (FoodTypeListActivity.class) to set as headlabel in (MainTabActivity.class) and send id of food type (FoodTypeListActivity.class) to (FoodListActivity.class)

How do i implement putExtra to send data to different activity in on ListItem click of FoodTypeListActivity.class

Now i have the the following code in FoodTypeListActivity.class

lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,int position, long id) {


              if(position==0){
                Intent i = new Intent(FoodTypeListActivity.this, MainTabActivity.class);  

                i.putExtra("foodTypeID", 3);
                i.putExtra("foodTypeName", "Breakfast");
                startActivity(i);

              } 

            }
          });

Thanks 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-28T00:40:06+00:00Added an answer on May 28, 2026 at 12:40 am

    You should just use shared preference.

    In your listview click use this to put the values in shared preference.

      SharedPreferences items = getSharedPreferences("my_food_data", 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putInt("foodTypeID", 3);
      editor.putString("foodTypeName", "Breakfast"); 
      editor.commit(); //VERY important
    

    Now to pull the data out in ANY activity use..

       SharedPreferences items = getSharedPreferences("my_food_data", 0);
       int foodId = settings.getInt("foodTypeId", 0);
       String foodTitle = items.getString("foodTypeName", "No Name"); //the default value of of "no name will be used if nothing is in the preference file.
    

    I think this works well for what you are trying to do.

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

Sidebar

Related Questions

I have an activity which is called by a few other activities. For example,
Example: I have an class that inherits from UIImageView. An object creates an instance
Example I have a repository class (DAL): public class MyRepository : IMyRepository { public
suppose that you have 3 Activities (A, B and C) and Activity A starts
In various activities I have very similar methods. For example: @Override public void onClick(View
Hi i'm facing this problem. I have an application with 2 activities: -Activity A
I followed the example in the Android website to create a tab activity with
I have two activities, one is main and I have another activity called Test
I have four activities A,B,C,D. I am passing an text from activity A to
If I for example have <p> some long text </p> on my HTML page,

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.