April Smith
April Smith

Reputation: 1830

Is it possible to use actionbar from Sherlock accompany with ViewPagerIndicator from JakeWharton

I wanna create a pager+tab which, use the library from ViewPagerIndicator and use Actionbar from Sherlock. Is that possible? I try with the following code and getSupportFragmentManager() error. If I extends FragmentActivity instead of ShelockActivity, it won't show this error but, .setShowAsAction show error instead.

public class MainActivity extends SherlockActivity  {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.simple_tabs);

            //method getSupportFragmentManager() is undefined for the type MainActivity
            FragmentPagerAdapter adapter = new GoogleMusicAdapter(getSupportFragmentManager());

            ViewPager pager = (ViewPager)findViewById(R.id.pager);
            pager.setAdapter(adapter);

            TabPageIndicator indicator = (TabPageIndicator)findViewById(R.id.indicator);
            indicator.setViewPager(pager);
        }

        @Override
        public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
              menu.add("Search")
              .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

          menu.add("Refresh")
              .setIcon(R.drawable.ic_refresh)
              .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

          return true;
        }
  ....
}

Upvotes: 0

Views: 258

Answers (1)

Darwind
Darwind

Reputation: 7371

The short answer is, yes it's possible.

Have a look at this tutorial - helped me when I was creating a project with both libraries:

http://droidista.blogspot.dk/2012/08/making-actionbarsherlock-and.html

Upvotes: 2

Related Questions