ActionBarSherlock Tabs with Fragments not correctly
I've started a small application that I'm modeling after ABS: Fragments ->
Tabs and Pager.
In my app, I've created a main activity that looks like this:
public class MainActivity extends SherlockFragmentActivity {
TabHost mTabHost;
ViewPager mViewPager;
TabsAdapter mTabsAdapter;
ConfigDBHelper sily_db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.setup();
mViewPager = (ViewPager)findViewById(R.id.pager);
mTabsAdapter = new TabsAdapter(this,mTabHost,mViewPager);
mTabsAdapter.addTab(mTabHost.newTabSpec("home").setIndicator("Home"),
MainSupport.CountingFragment.class, null);
/*
mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
LoaderCursorSupport.CursorLoaderListFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"),
LoaderCustomSupport.AppListFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
*/
if (savedInstanceState != null) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
}
The code, eventually, will contain multiple tabs - but for now, I've
created only 1.
My activity_main layout file is fragment_tabs_pager.xml from ABS renamed.
My MainSupport is FragmentStackSupport.java but renamed.
When I run my application, instead of seeing a "tab" at the top of the
screen, I'm seeing the one and only tab in the MIDDLE of the view -
covering both the fragment_stack.xml layout AND the hello_world.xml
layout.
My suspicion is I've got a missing or incorrect directive someplace, but
am unsure where. Especially as I skipped past the SimpleList.java module
that is in the samples.
Any ideas?
No comments:
Post a Comment