Im trying to figure out how to implement Actionbar items based on the Fragment that is being loaded inside my viewpager. My code is below and im just trying to figure out the be
Im trying to figure out how to implement Actionbar items based on the Fragment that is being loaded inside my viewpager.
That happens automatically. Just have the fragments call setHasOptionsMenu(true)
, then implement onCreateOptionsMenu()
and onOptionsItemSelected()
. The Fragment*PagerAdapter
will arrange to repopulate the action bar after a page change, to remove action bar items from the previous page and introduce action bar items from the newly-current page.
Here is a sample project demonstrating having action bar items come and go, as only odd-numbered pages (for 1-based indexes, what the user sees) have action bar items.