First,thanks for your response.
I'm sorry I didn't explain my problem clearly.
FileTransferMainActivity (extends SherlockFragmentActivity) actually
contains three fragments.
My app crashed down in the red color part(Shown below,from
FileTransferMainActivity).The previous code I send to you is From
MainTabActivity. I can use FileTransferMainActivity with actionbar
separately but i can't use it in the case of adding the
FileTransferMainActivity as one tab of tabhost.Is that I can't use ABS in
such situation.
I am Looking forward to your reply!My English is not good,I hope you can
understand what i write. Thank you.
@Override
protected void onCreate(Bundle paramBundle) {
setTheme(R.style.Theme_Sherlock);
super.onCreate(paramBundle);
setContentView(R.layout.rc_transfer_file_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
init();
}
private void init() {
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
getSupportActionBar().setIcon(getResources().getDrawable(R.drawable.rc_main _online));
getSupportActionBar().setTitle(getString(R.string.rc_main_connection_state_ online));
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayUseLogoEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
mLayoutInflator = (LayoutInflater)
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mViewPager = (ViewPager) findViewById(R.id.rc_transfer_file_main_pagers);
mMainAdapter = new FileTransferMainAdapter(getSupportActionBar(), this,
mViewPager);
mMainAdapter.addTab(getString(R.string.rc_filetransfer_main_tab_file),
R.drawable.rc_filetransfer_main_tab_file, NewShareFilesFragment.class,
null);
mMainAdapter.addTab(getString(R.string.rc_filetransfer_main_tab_category),
R.drawable.rc_filetransfer_main_tab_category,
NewCategoryFilesFragment.class,
null);
mMainAdapter.addTab(getString(R.string.rc_filetransfer_main_tab_uploadList) ,
R.drawable.rc_filetransfer_main_tab_uploadlist,
NewUploadProgressListFragment.class, null);
mViewPager.setAdapter(mMainAdapter);
}
2012/9/12 Jake Wharton <jakewhar...@gmail.com>
> You cannot use ABS with ActivityGroup and/or LocalActivityManager. Use
> fragments if you need logic to be encapsulated around views.
> ---
> Jake Wharton
> http://about.me/jakewharton
> On Tue, Sep 11, 2012 at 7:32 PM, johnson_z <zhangjianxin0...@gmail.com>wrote:
>> @Override
>> protected void onCreate(Bundle savedInstanceState) {
>> setTheme(R.style.Theme_Sherlock);
>> super.onCreate(savedInstanceState);
>> setContentView(R.layout.rc_hd_main);
>> Resources res = getResources();
>> TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
>> LocalActivityManager lam = new LocalActivityManager(this, false);
>> lam.dispatchCreate(savedInstanceState);
>> tabHost.setup(lam);
>> TabHost.TabSpec spec;
>> spec = tabHost.newTabSpec("favs")
>> .setIndicator("Favorites",
>> res.getDrawable(R.drawable.rc_main_menu_sharefile))
>> .setContent(new Intent().setClass(this,
>> FileTransferMainActivity.class));
>> tabHost.addTab(spec);
>> // add tabs to tab host
>> spec = tabHost.newTabSpec("search")
>> .setIndicator("Search", res.getDrawable(R.drawable.rc_main_menu_touchpad))
>> .setContent(new Intent().setClass(this, TouchPadActivity.class));
>> tabHost.addTab(spec);
>> spec = tabHost.newTabSpec("lenses")
>> .setIndicator("Lenses", res.getDrawable(R.drawable.rc_main_menu_ppt))
>> .setContent(new Intent().setClass(this, PptPatternActivity.class));
>> tabHost.addTab(spec);
>> }
>> I'm trying to use actionbar&viewpager in FileTransferMainActivity.But
>> getSupportActionBar() is always return null.I can'n move forward with my
>> app if i won't solve the problem.please help.
>> Always i had set the application with style :Theme.Sherlock.