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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:16:32+00:00 2026-06-13T02:16:32+00:00

I’m trying to build something that I’m not sure if it’s possible. I have

  • 0

I’m trying to build something that I’m not sure if it’s possible. I have Fragment tabs
(using FragmentActivity, TabHost and TabWidget as my fragment tabs container)
and in each of the fragments I want to have, as top bar, another fragments. You can look at this as – bottom bar constructed of types of items, and top bar that would be filters. I want to snap between the filters in regular gesture.

The behavior of my app is the following: I can see the main activity in which the first fragment sits, i can see the top/bottom bar, but i can’t see the view(fragment) of the first top bar category. When I’m trying to snap to the other category nothing happens.

This is the code for the fragment:

Public class Tab1Fragment extends Fragment {

private ViewPager _mViewPager;
private ViewPagerAdapter _adapter;
private View child;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    if (container == null) {
        return null;
    }

    child = inflater.inflate(R.layout.tab_frag1_layout, container);

    _mViewPager = (ViewPager) child.findViewById(R.id.viewPager);
    _adapter = new ViewPagerAdapter(GlobalContext.getAppContext(),getFragmentManager());
    _mViewPager.setCurrentItem(0);

    new setAdapterTask().execute();

    return (LinearLayout) inflater.inflate(R.layout.tab_frag1_layout,
            container, false);
}

private class setAdapterTask extends AsyncTask<Void, Void, Void> {
    protected Void doInBackground(Void... params) {
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        _mViewPager.setAdapter(_adapter);
        _mViewPager.setCurrentItem(0);
    }
}

public void onActivityCreated(Bundle bdl) {
    super.onActivityCreated(bdl);

    _mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int position) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int position) {
            // TODO Auto-generated method stub
            switch (position) {
            case 0:
                child.findViewById(R.id.first_tab).setVisibility(
                        View.VISIBLE);
                child.findViewById(R.id.second_tab)
                        .setVisibility(View.GONE);
                break;

            case 1:
                child.findViewById(R.id.first_tab).setVisibility(View.GONE);
                child.findViewById(R.id.second_tab).setVisibility(
                        View.VISIBLE);
                break;
            }
        }

    });

}

}

This is the xml for the outer Fragment:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical" >  

<TableLayout
    style="@style/layout_f_w"
    android:stretchColumns="*" >
    <TableRow
        android:id="@+id/tableRow1"
        android:background="#dddddd"
        style="@style/layout_wrap">

          <!-- First Tab -->
            <LinearLayout
            style="@style/layout_f_w"
            android:id="@+id/first_text"
            android:orientation="vertical" >

                  <TextView
                    android:id="@+id/textView1"
                    style="@style/text_title"
                    android:text="Tab1" />
           </LinearLayout>

        <!-- Second Tab -->
            <LinearLayout
            style="@style/layout_f_w"
            android:id="@+id/second_text"
            android:orientation="vertical" >

                <TextView
                    android:id="@+id/textView1"
                    style="@style/text_title"
                    android:text="Tab2" />

           </LinearLayout>

    </TableRow>
 </TableLayout>
 <!-- Include Tab Indicator  -->
 <include layout="@layout/indicator" android:layout_width="fill_parent"
  android:layout_height="wrap_content"  />

<android.support.v4.view.ViewPager
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:id="@+id/viewPager" />
</LinearLayout>

This is an example for my first category fragment(the fragment category that inside the first fragment):

public class LayoutOne extends Fragment {


public static Fragment newInstance(Context context) {
    LayoutOne f = new LayoutOne();  

    return f;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.layout_one, null);       
    return root;
}

}

Please help me 🙁

This is my Fragment Adapter:

public class ViewPagerAdapter extends FragmentStatePagerAdapter {
private Context _context;

public ViewPagerAdapter(Context context, FragmentManager fm) {
    super(fm);  
    _context=context;

    }
@Override
public Fragment getItem(int position) {
    Fragment f = new Fragment();
    switch(position){
    case 0:
        f=LayoutOne.newInstance(_context);  
        break;
    case 1:
        f=LayoutTwo.newInstance(_context);  
        break;
    }
    return f;
}
@Override
public int getCount() {
    return 2;
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
    // TODO Auto-generated method stub
    return false;
}

}
  • 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-13T02:16:34+00:00Added an answer on June 13, 2026 at 2:16 am

    Finally we have nested fragments in 4.2 and compatibility http://developer.android.com/about/versions/jelly-bean.html

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put

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.