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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:14:56+00:00 2026-06-01T16:14:56+00:00

I have the following problem. I am in a tabActivity with 2 tabs. Every

  • 0

I have the following problem.

I am in a tabActivity with 2 tabs. Every tab will launch the same activity, but there is a onTabChangeListener.
In this tabchange listener i need to set up the listview adapter that is different for each activity.
So i will have two different lists, and i want to change their adapter from TabActivity, from this onTabchangeListener, but i get the following error: system services not available to activities before oncreate()
The code for tabs is:

  host = getTabHost();

    host.addTab(host.newTabSpec(TAG_AVAILABLE).setIndicator("First Tab")
            .setContent(new Intent(this, MyActivity.class)));
    host.addTab(host.newTabSpec(TAG_DOWNLOAD).setIndicator("Second Tab ")
            .setContent(new Intent(this, MyActivity.class)));
    host.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String s) {
            MyActivity myActivity = new MyActivity();
            int i = getTabHost().getCurrentTab();
            if (i == FIRST_TAB) {
                setAdapterForMyActivity(firstAdapter);       
            }
            }
            if (i == SECOND_TAB) {
                 setAdapterForMyActivity(secondAdapter);        
            }
            }
        }
    });

}

The main question is how to set adapter of an listView which is in an Activity from TabActivity.
Thank you very much.

  • 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-01T16:14:57+00:00Added an answer on June 1, 2026 at 4:14 pm

    If you want to pass an Adapter to a child activity, you’ll need a global shared object of some kind. One option would be to pass the adapter to an Application object in the parent TabActivity and then retrieve that in the child activity.

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

Sidebar

Related Questions

I have following problem: I have a TabActivity which works well. Inside, there is
I have following problem: I have built a tabbar application with 4 tabs. I
My problem is, that I have got a TabActivity, which has 4 Tabs right
Have following problem, the infowindow, gives the same result on different markers. When I
I have following problem. I have a team page like this example: http://www.social-markets.de/social-commerce-team.html small
I have following problem. I use this tutorial to creating a multiple file uploader:
I have following problem. I worked two days on a solution but I cannot
I have a tabactivity with several tabs. Each tab has an ActivityGroup associated with
I have following problem Bundle bundle = new Bundle(); bundle.putString(url, someUrl); This works fine.
I have following problem. I have created a tab based Application with three Views

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.