本文整理汇总了Java中android.support.v4.widget.DrawerLayout.setDrawerLockMode方法的典型用法代码示例。如果您正苦于以下问题:Java DrawerLayout.setDrawerLockMode方法的具体用法?Java DrawerLayout.setDrawerLockMode怎么用?Java DrawerLayout.setDrawerLockMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.widget.DrawerLayout
的用法示例。
在下文中一共展示了DrawerLayout.setDrawerLockMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPrimaryItem
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object)
{
if(service != null)
{
int id = service.getTabByPosition(position).id;
service.setFrontTab(id);
View nickList = (View)mainScreen.findViewById(R.id.nick_list);
DrawerLayout drawerLayout = (DrawerLayout)mainScreen.findViewById(R.id.drawerLayout);
if (service.getFrontTab().nickList == null)
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, nickList);
else if (drawerLayout.getDrawerLockMode(nickList) == DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, nickList);
mainScreen.getNickListAdapter().notifyDataSetChanged();
}
curTab = (TabFragment)object;
}
示例2: onTabNickListChanged
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
public void onTabNickListChanged(int tabId)
{
if(getService().getFrontTab().id == tabId)
{
View nickList = (View)findViewById(R.id.nick_list);
DrawerLayout drawerLayout = (DrawerLayout)findViewById(R.id.drawerLayout);
if (getService().getFrontTab().nickList == null)
{
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, nickList);
}
else if (drawerLayout.getDrawerLockMode(nickList) == DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, nickList);
notifyDataSetChanged();
}
}
示例3: onCreate
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// listen for navigation events
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
if (mNavigationView != null) {
mNavigationView.setNavigationItemSelectedListener(this);
// select the correct nav menu item
MenuItem menuItem = mNavigationView.getMenu().findItem(getMenuItem());
if (menuItem != null)
menuItem.setChecked(true);
if (DataUtils.hideDrawer(this)) {
// set up the hamburger icon to open and close the drawer_logged_in
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, 0);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
} else {
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
mDrawerLayout.setScrimColor(0x00000000);
mDrawerLayout.requestDisallowInterceptTouchEvent(true);
if (mToolbar != null) {
RelativeLayout.LayoutParams mToolbarLayoutParams = ((RelativeLayout.LayoutParams) mToolbar.getLayoutParams());
mToolbarLayoutParams.setMargins(mToolbarLayoutParams.leftMargin + getResources().getDimensionPixelSize(R.dimen.drawer_size), mToolbarLayoutParams.topMargin, mToolbarLayoutParams.rightMargin, mToolbarLayoutParams.bottomMargin);
}
if (mMainContent != null) {
RelativeLayout.LayoutParams mMainContentLayoutParams = ((RelativeLayout.LayoutParams) mMainContent.getLayoutParams());
mMainContentLayoutParams.setMargins(mMainContentLayoutParams.leftMargin + getResources().getDimensionPixelSize(R.dimen.drawer_size), mMainContentLayoutParams.topMargin, mMainContentLayoutParams.rightMargin, mMainContentLayoutParams.bottomMargin);
}
}
}
}
示例4: onCreate
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (loggedIn) {
Intent myIntent = new Intent(MainActivity.this, PostCallActivity.class);
MainActivity.this.startActivity(myIntent);
} else {
Snackbar.make(findViewById(R.id.container), getString(R.string.error_logged_in), Snackbar.LENGTH_LONG).setAction("Action", null).show();
}
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
if (savedInstanceState == null) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.replace(R.id.container, WelcomeFragment.newInstance(loggedIn));
ft.commit();
}
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.content_frame);
if (((ViewGroup.MarginLayoutParams)frameLayout.getLayoutParams()).leftMargin == (int) getResources().getDimension(R.dimen.drawer_size)) {
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
drawer.setScrimColor(Color.TRANSPARENT);
isDrawerLocked = true;
Log.d(TAG, "Drawer locked");
}
if (!isDrawerLocked) {
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
}
}