0

I have a FragmentActivity and some fragment in my app. i need to have Swip ActionBar-Tabs Just inside one fragment , but when i use ActionBar and ViewPager in my project to make Swip ActionBar Tab , make ActionBar in all of fragment No just in one,

hove i can make ActionBar just inside one fragment that not shown in other fragment?

    actionabar = getActionBar();
    actionabar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    viewpager = (ViewPager) findViewById(R.id.pager);
    FragmentManager fm = getSupportFragmentManager();

    /** Defining a listener for pageChange */
    ViewPager.SimpleOnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener(){
        @Override
        public void onPageSelected(int position) {              
            super.onPageSelected(position);
            actionabar.setSelectedNavigationItem(position);             
        }           
    };

    /** Setting the pageChange listner to the viewPager */
    viewpager.setOnPageChangeListener(pageChangeListener);

    /** Creating an instance of FragmentPagerAdapter */
    MyFragmentPagerAdapter fragmentPagerAdapter = new MyFragmentPagerAdapter(fm);

    viewpager.setAdapter(fragmentPagerAdapter);
    actionabar.setDisplayShowTitleEnabled(true);

    Tab tab = actionabar.newTab().setText("My Friends").setTabListener(tabListener);
    actionabar.addTab(tab);
    tab = actionabar.newTab().setText("Android Version").setTabListener(tabListener);                               
    actionabar.addTab(tab);       
    tab = actionabar.newTab().setText("Android Phones").setTabListener(tabListener);                               
    actionabar.addTab(tab);   
spm
  • 80
  • 8
Saeid
  • 2,261
  • 4
  • 27
  • 59

1 Answers1

0

Use TabHost (http://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html) instead of ActionBar navigation mode.

Stepango
  • 4,721
  • 3
  • 31
  • 44
  • it possible to adding sweep inside TabHost? – Saeid Jul 16 '14 at 07:53
  • I dont try it before but you could use ActionBar hover mode and animate ActionBar view(http://stackoverflow.com/questions/20023483/how-to-get-actionbar-view) using ObjectAnimator or ViewPropertyAnimator – Stepango Jul 16 '14 at 11:42