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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:08:22+00:00 2026-06-02T08:08:22+00:00

I write a method to generate gallery at run time. private Gallery createGallery(ImageAdapter imageAdapter)

  • 0

I write a method to generate gallery at run time.

private Gallery createGallery(ImageAdapter imageAdapter) {

    Gallery sampleGallery = new Gallery(getApplicationContext());
    sampleGallery.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    sampleGallery.setGravity(Gravity.FILL_VERTICAL);
    sampleGallery.setSpacing(5);
    sampleGallery.setAdapter(imageAdapter);
    sampleGallery.setSelection(1);
    return sampleGallery;

}

Then I create a galley and try to set it to a Tab Layout.

final TabHost mTabHost = (TabHost) findViewById(R.id.tabHost);
    mTabHost.setup();
    Gallery tabGallery = createGallery(brkingNewAdapter); // my image adapter
    tabGallery.setId(R.id.gallery_1);
    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1")
            .setContent(R.id.gallery_1));

R.id.gallery_1 is defined as mentions in here.

I get a exception as follows.

Could not create tab content because could not find view with id 2130968576

Any help on this?

Thank you in advance.

  • 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-02T08:08:24+00:00Added an answer on June 2, 2026 at 8:08 am

    You should take a look at TabContentFactory.

    The solution for you would be to implement TabContentFactory and return the Gallery instance in the createTabContent method and use setContent(TabHost.TabContentFactory contentFactory) method in addTab.

    class GalleryContentFactory implements TabContentFactory{
        private ImageAdapter imageAdapter;
        public GalleryContentFactory(ImageAdapter imageAdapter){
            this.imageAdapter = imageAdapter;
        }
        public View createTabContent(String tag){
            Gallery sampleGallery = new Gallery(getApplicationContext());
            sampleGallery.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
            sampleGallery.setGravity(Gravity.FILL_VERTICAL);
            sampleGallery.setSpacing(5);
            sampleGallery.setAdapter(imageAdapter);
            sampleGallery.setSelection(1);
            return sampleGallery;
        }
    }
    

    and for adding to the tab:

    GalleryContentFactory galleryFactory = new GalleryContentFactory(brkingNewAdapter);
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2")
                .setContent(galleryFactory));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a method that run multiple threads and I want before
I'm looking to write an efficient n-order Markov chain method to generate random text
I'm trying to write a php script that will generate a variety of new
Is there some way I can catch when a method generates a write to
Hi I'm writing a write() method for my character driver and I was wondering
I have a class using ReaderWriterLockSlim with a read method and a write method
i write a method that loops through an array of buttons and checks if
How do you write a method/message with multiple parameters? EDIT: Like multiple parameters for
I wanted to write a method with an argument that defaults to a member
When I write a method and I want to comment it, I write 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.