|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.support.v4.app.ActionBarDrawerToggle
public class ActionBarDrawerToggle
This class provides a handy way to tie together the functionality of
DrawerLayout
and the framework ActionBar
to implement the recommended
design for navigation drawers.
To use ActionBarDrawerToggle
, create one in your Activity and call through
to the following methods corresponding to your Activity callbacks:
onConfigurationChanged
onOptionsItemSelected
Call syncState()
from your Activity
's
onPostCreate
to synchronize the indicator
with the state of the linked DrawerLayout after onRestoreInstanceState
has occurred.
ActionBarDrawerToggle
can be used directly as a
DrawerLayout.DrawerListener
, or if you are already providing your own listener,
call through to each of the listener methods from your own.
Constructor Summary | |
---|---|
ActionBarDrawerToggle(android.app.Activity activity,
DrawerLayout drawerLayout,
int drawerImageRes,
int openDrawerContentDescRes,
int closeDrawerContentDescRes)
Construct a new ActionBarDrawerToggle. |
Method Summary | |
---|---|
boolean |
isDrawerIndicatorEnabled()
|
void |
onConfigurationChanged(android.content.res.Configuration newConfig)
This method should always be called by your Activity 's
onConfigurationChanged
method. |
void |
onDrawerClosed(android.view.View drawerView)
DrawerLayout.DrawerListener callback method. |
void |
onDrawerOpened(android.view.View drawerView)
DrawerLayout.DrawerListener callback method. |
void |
onDrawerSlide(android.view.View drawerView,
float slideOffset)
DrawerLayout.DrawerListener callback method. |
void |
onDrawerStateChanged(int newState)
DrawerLayout.DrawerListener callback method. |
boolean |
onOptionsItemSelected(android.view.MenuItem item)
This method should be called by your Activity 's
onOptionsItemSelected method. |
boolean |
onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item)
This method should be called by your SherlockActivity 's
onOptionsItemSelected method. |
void |
setDrawerIndicatorEnabled(boolean enable)
Enable or disable the drawer indicator. |
void |
syncState()
Synchronize the state of the drawer indicator/affordance with the linked DrawerLayout. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActionBarDrawerToggle(android.app.Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes)
The given Activity
will be linked to the specified DrawerLayout
.
The provided drawer indicator drawable will animate slightly off-screen as the drawer
is opened, indicating that in the open state the drawer will move off-screen when pressed
and in the closed state the drawer will move on-screen when pressed.
String resources must be provided to describe the open/close drawer actions for accessibility services.
activity
- The Activity hosting the drawerdrawerLayout
- The DrawerLayout to link to the given Activity's ActionBardrawerImageRes
- A Drawable resource to use as the drawer indicatoropenDrawerContentDescRes
- A String resource to describe the "open drawer" action
for accessibilitycloseDrawerContentDescRes
- A String resource to describe the "close drawer" action
for accessibilityMethod Detail |
---|
public void syncState()
This should be called from your Activity
's
onPostCreate
method to synchronize after
the DrawerLayout's instance state has been restored, and any other time when the state
may have diverged in such a way that the ActionBarDrawerToggle was not notified.
(For example, if you stop forwarding appropriate drawer events for a period of time.)
public void setDrawerIndicatorEnabled(boolean enable)
When the indicator is disabled, the ActionBar
will revert to displaying
the home-as-up indicator provided by the Activity
's theme in the
android.R.attr.homeAsUpIndicator
attribute instead of the animated
drawer glyph.
enable
- true to enable, false to disablepublic boolean isDrawerIndicatorEnabled()
setDrawerIndicatorEnabled(boolean)
public void onConfigurationChanged(android.content.res.Configuration newConfig)
Activity
's
onConfigurationChanged
method.
newConfig
- The new configurationpublic boolean onOptionsItemSelected(android.view.MenuItem item)
Activity
's
onOptionsItemSelected
method.
If it returns true, your onOptionsItemSelected
method should return true and
skip further processing.
item
- the MenuItem instance representing the selected menu item
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item)
SherlockActivity
's
onOptionsItemSelected
method.
If it returns true, your onOptionsItemSelected
method should return true and
skip further processing.
item
- the MenuItem instance representing the selected menu item
public void onDrawerSlide(android.view.View drawerView, float slideOffset)
DrawerLayout.DrawerListener
callback method. If you do not use your
ActionBarDrawerToggle instance directly as your DrawerLayout's listener, you should call
through to this method from your own listener object.
onDrawerSlide
in interface DrawerLayout.DrawerListener
drawerView
- The child view that was movedslideOffset
- The new offset of this drawer within its range, from 0-1public void onDrawerOpened(android.view.View drawerView)
DrawerLayout.DrawerListener
callback method. If you do not use your
ActionBarDrawerToggle instance directly as your DrawerLayout's listener, you should call
through to this method from your own listener object.
onDrawerOpened
in interface DrawerLayout.DrawerListener
drawerView
- Drawer view that is now openpublic void onDrawerClosed(android.view.View drawerView)
DrawerLayout.DrawerListener
callback method. If you do not use your
ActionBarDrawerToggle instance directly as your DrawerLayout's listener, you should call
through to this method from your own listener object.
onDrawerClosed
in interface DrawerLayout.DrawerListener
drawerView
- Drawer view that is now closedpublic void onDrawerStateChanged(int newState)
DrawerLayout.DrawerListener
callback method. If you do not use your
ActionBarDrawerToggle instance directly as your DrawerLayout's listener, you should call
through to this method from your own listener object.
onDrawerStateChanged
in interface DrawerLayout.DrawerListener
newState
- The new drawer motion state
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |