本文整理汇总了Java中android.widget.Toolbar.setNavigationOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setNavigationOnClickListener方法的具体用法?Java Toolbar.setNavigationOnClickListener怎么用?Java Toolbar.setNavigationOnClickListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Toolbar
的用法示例。
在下文中一共展示了Toolbar.setNavigationOnClickListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_detail);
postponeEnterTransition();
TransitionSet transitions = new TransitionSet();
Slide slide = new Slide(Gravity.BOTTOM);
slide.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.interpolator.linear_out_slow_in));
slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
transitions.addTransition(slide);
transitions.addTransition(new Fade());
getWindow().setEnterTransition(transitions);
Intent intent = getIntent();
sharedElementCallback = new DetailSharedElementEnterCallback(intent);
setEnterSharedElementCallback(sharedElementCallback);
initialItem = intent.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0);
setUpViewPager(intent.<Photo>getParcelableArrayListExtra(IntentUtil.PHOTO));
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(navigationOnClickListener);
super.onCreate(savedInstanceState);
}
示例2: ActionBarDrawerToggle
import android.widget.Toolbar; //导入方法依赖的package包/类
/**
* In the future, we can make this constructor public if we want to let developers customize
* the
* animation.
*/
ActionBarDrawerToggle(Activity activity, Toolbar toolbar, DrawerLayout drawerLayout,
DrawerArrowDrawable slider, @StringRes int openDrawerContentDescRes,
@StringRes int closeDrawerContentDescRes) {
if (toolbar != null) {
mActivityImpl = new ToolbarCompatDelegate(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mDrawerIndicatorEnabled) {
toggle();
} else if (mToolbarNavigationClickListener != null) {
mToolbarNavigationClickListener.onClick(v);
}
}
});
} else if (activity instanceof DelegateProvider) { // Allow the Activity to provide an impl
mActivityImpl = ((DelegateProvider) activity).getDrawerToggleDelegate();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
mActivityImpl = new JellybeanMr2Delegate(activity);
} /*else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mActivityImpl = new IcsDelegate(activity);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mActivityImpl = new HoneycombDelegate(activity);
}*/ else {
mActivityImpl = new DummyDelegate(activity);
}
mDrawerLayout = drawerLayout;
mOpenDrawerContentDescRes = openDrawerContentDescRes;
mCloseDrawerContentDescRes = closeDrawerContentDescRes;
if (slider == null) {
mSlider = new DrawerArrowDrawable(mActivityImpl.getActionBarThemedContext());
} else {
mSlider = slider;
}
mHomeAsUpIndicator = getThemeUpIndicator();
}
示例3: initToolBar
import android.widget.Toolbar; //导入方法依赖的package包/类
private void initToolBar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mDrawerLayout.openDrawer(mNavigationView);
}
});
}
示例4: initToolbar
import android.widget.Toolbar; //导入方法依赖的package包/类
private void initToolbar(Category category) {
mToolbar = (Toolbar) findViewById(R.id.toolbar_activity_quiz);
mToolbar.setTitle(category.getName());
mToolbar.setNavigationOnClickListener(mOnClickListener);
if (mSavedStateIsPlaying) {
// the toolbar should not have more elevation than the content while playing
mToolbar.setElevation(0);
}
}
示例5: setActionBar
import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
@RequiresApi(21)
public void setActionBar(@Nullable Toolbar toolbar) {
super.setActionBar(toolbar);
if (null == toolbar)
return;
if (null == mToolbarListener) {
mToolbarListener = new ToolbarNavigationOnClickListener();
}
toolbar.setNavigationOnClickListener(mToolbarListener);
}
示例6: onCreate
import android.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_detail);
postponeEnterTransition();
TransitionSet transitions = new TransitionSet();
Slide slide = new Slide(Gravity.BOTTOM);
slide.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.interpolator.linear_out_slow_in));
slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
transitions.addTransition(slide);
transitions.addTransition(new Fade());
getWindow().setEnterTransition(transitions);
Intent intent = getIntent();
sharedElementCallback = new DetailSharedElementEnterCallback(intent);
setEnterSharedElementCallback(sharedElementCallback);
try {
initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
} catch (NumberFormatException e) {
initialItem = 0;
}
PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
@Override
public void success(ArrayList<Photo> photos) {
setUpViewPager(photos);
findViewById(android.R.id.empty).setVisibility(View.GONE);
}
@Override
public void error() {
finishAfterTransition();
}
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(navigationOnClickListener);
super.onCreate(savedInstanceState);
}