本文整理汇总了Java中android.support.v4.app.ActionBarDrawerToggle.syncState方法的典型用法代码示例。如果您正苦于以下问题:Java ActionBarDrawerToggle.syncState方法的具体用法?Java ActionBarDrawerToggle.syncState怎么用?Java ActionBarDrawerToggle.syncState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.ActionBarDrawerToggle
的用法示例。
在下文中一共展示了ActionBarDrawerToggle.syncState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initViews
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
private void initViews() {
mDrawerLayoutView = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerView = mDrawerLayoutView.findViewById(R.id.drawer);
mDrawerSnapshotsView = mDrawerView.findViewById(R.id.snapshots);
mDrawerSnapshotsView.setOnClickListener(this);
mDrawerProfilesView = mDrawerView.findViewById(R.id.profiles);
mDrawerProfilesView.setOnClickListener(this);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayoutView,
R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
mDrawerLayoutView.setDrawerListener(new MyDrawerListener());
mDrawerLayoutView.openDrawer(mDrawerView);
mSnapshotsListFrag.setMenuVisibility(false);
// Sync the toggle state after onRestoreInstanceState has occurred.
// The following line must be called, otherwise the provided drawer image will be used.
mDrawerToggle.syncState();
}
示例2: onCreate
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.components_view);
Injector.inject(this);
ButterKnife.inject(this);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.fragmentPlaceholder, new ComponentsFragment(), "blur").commit();
}
drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
actionBarDrawerToggle = new ActionBarDrawerToggle(
this, /* host Activity */
drawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description */
R.string.drawer_close /* "close drawer" description */
) {
public void onDrawerClosed(View view) {
getActionBar().setTitle(ComponentsActivity.this.getTitle());
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(ComponentsActivity.this.getTitle());
}
};
drawerLayout.setDrawerListener(actionBarDrawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
actionBarDrawerToggle.syncState();
}
示例3: initNavigationDrawer
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
private void initNavigationDrawer() {
//Log.d(TAG, "initNavigationDrawer");
if (mDrawerLayout == null || mDrawerList == null) {
//Get views
mDrawerLayout = (DrawerLayout) this.findViewById(R.id.drawer_layout);
mDrawerList = (ExpandableListView) this.findViewById(R.id.left_drawer);
//Set onClickListeners
mDrawerList.setOnGroupClickListener(new DrawerItemClickListener(this, mDrawerLayout, mDrawerList));
mDrawerList.setOnChildClickListener(new DrawerItemClickListener(this, mDrawerLayout, mDrawerList));
//NavDrawer Initialization
mAdapter = new ExpandableDrawerAdapter(this, mMapState.getDrawerItems());
mDrawerList.setAdapter(mAdapter);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
mAdapter.notifyDataSetInvalidated();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerList.setDividerHeight(0);
mDrawerList.setBackgroundColor(Color.WHITE);
mDrawerToggle.syncState();
//Enable and show navigation drawer icon
try {
getActionBar().setDisplayHomeAsUpEnabled(true);
}catch (NullPointerException e){
e.printStackTrace();
}
getActionBar().setHomeButtonEnabled(true);
}
}
示例4: initializeDrawer
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
/**
* Sets up the UI for the navigation drawer.
*/
private void initializeDrawer() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer,
R.string.show, R.string.hide);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
mDrawerToggle.syncState();
}
示例5: initNavDrawer
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
private void initNavDrawer() {
MyLog.entry();
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
getActionBar().setTitle(getTitle());
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(getString(getApplicationInfo().labelRes));
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
};
drawerLayout.setDrawerListener(drawerToggle);
drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
final ActionBar ab = getActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
}
navDrawerItems.clear();
final ViewGroup drawerItemsListContainer = (ViewGroup) findViewById(R.id.navdrawer_items_container);
drawerItemsListContainer.removeAllViews();
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.HOME);
addNavDrawerSeparator(drawerItemsListContainer);
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.VIEW_MONSTER_INFO);
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.VIEW_CAPTURED_DATA);
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.MANAGE_IGNORE_LIST);
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.FILTER_FRIENDS);
addNavDrawerSeparator(drawerItemsListContainer);
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.SETTINGS);
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.CHANGELOG);
if (new MockCaptureHelper(this).hasMockData()) {
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.MOCK_CAPTURE);
}
addNavDrawerItem(drawerItemsListContainer, NavigationDrawerItem.ABOUT);
drawerToggle.syncState();
MyLog.exit();
}
示例6: updateNavigationDrawer
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
private void updateNavigationDrawer() {
m_lists = contextsAndProjects();
if (m_lists.size() == 0) {
if (m_drawerLayout != null) {
// No contexts or projects, disable navigation drawer
m_drawerLayout.setDrawerLockMode(
DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
} else {
m_drawerList.setVisibility(View.GONE);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
} else {
if (m_drawerLayout != null) {
m_drawerLayout.setDrawerLockMode(
DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
m_drawerToggle = new ActionBarDrawerToggle(this, /*
* host Activity
*/
m_drawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
R.string.quickfilter, /* "open drawer" description */
R.string.app_label /* "close drawer" description */
) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// Redraw menu to show or hide menu items
supportInvalidateOptionsMenu();
super.onDrawerSlide(drawerView, slideOffset);
}
};
// Set the drawer toggle as the DrawerListener
m_drawerLayout.setDrawerListener(m_drawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
m_drawerToggle.syncState();
} else {
m_drawerList.setVisibility(View.VISIBLE);
}
m_drawerList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
m_drawerList.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_list_item, R.id.left_drawer_text, m_lists));
setDrawerChoices();
// Set the list's click listener
m_drawerList.setOnItemClickListener(new DrawerItemClickListener());
}
}
示例7: onCreate
import android.support.v4.app.ActionBarDrawerToggle; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (userService.getMe() == null) {
activityStarter.startLogin(this);
finish();
return;
}
persistNewEvent();
if (eventService.getActiveEvent() == null) {
activityStarter.startStartEvent(this);
finish();
return;
}
setContentView(R.layout.event_details);
drawerToggle = new ActionBarDrawerToggle(
this,
drawerLayout,
R.drawable.ic_drawer,
R.string.nav_drawer_open_desc,
R.string.nav_drawer_close_desc
) {
public void onDrawerClosed(View view) {
if (newEvent != null) {
activityStarter.startEventDetails(EventDetails.this, newEvent, false);
newEvent = null;
}
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
}
};
drawerToggle.syncState();
setupMenuActions();
}