本文整理了Java中androidx.appcompat.widget.Toolbar.setNavigationOnClickListener()
方法的一些代码示例,展示了Toolbar.setNavigationOnClickListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.setNavigationOnClickListener()
方法的具体详情如下:
包路径:androidx.appcompat.widget.Toolbar
类名称:Toolbar
方法名:setNavigationOnClickListener
暂无
代码示例来源:origin: ankidroid/Anki-Android
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: alexvasilkov/GestureViews
/**
* Initializing top image expanding animation.
*/
private void initTopImage() {
views.fullImageToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
views.fullImageToolbar.setNavigationOnClickListener(view -> onBackPressed());
imageAnimator = GestureTransitions.from(views.appBarImage).into(views.fullImage);
// Setting up and animating image transition
imageAnimator.addPositionUpdateListener(this::applyFullImageState);
views.appBarImage.setOnClickListener(view -> {
getSettingsController().apply(views.fullImage);
imageAnimator.enterSingle(true);
});
}
代码示例来源:origin: ankidroid/Anki-Android
toolbar.setNavigationOnClickListener(v -> onNavigationPressed());
代码示例来源:origin: mikepenz/MaterialDrawer
this.mToolbar.setNavigationOnClickListener(toolbarNavigationListener);
代码示例来源:origin: alexvasilkov/GestureViews
/**
* Initializing pager and fullscreen mode.
*/
private void initPager() {
// Setting up pager adapter
pagerAdapter = new PhotoPagerAdapter(views.pager, getSettingsController());
pagerListener = new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
onPhotoInPagerSelected(position);
}
};
views.pager.setAdapter(pagerAdapter);
views.pager.addOnPageChangeListener(pagerListener);
views.pager.setPageTransformer(true, new DepthPageTransformer());
// Setting up pager toolbar
views.pagerToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
views.pagerToolbar.setNavigationOnClickListener(view -> onBackPressed());
// Enabling immersive mode by clicking on full screen image
pagerAdapter.setImageClickListener(() -> {
if (!listAnimator.isLeaving()) {
// Toggle immersive mode
showSystemUi(!isSystemUiShown());
}
});
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(
visibility -> views.pagerToolbar.animate().alpha(isSystemUiShown() ? 1f : 0f));
}
代码示例来源:origin: chrisbanes/PhotoView
toolbar.setTitle("Simple Sample");
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher
/**
* Adapts the navigation icon of the toolbar, which is shown, when the tab switcher is shown.
*/
private void adaptToolbarNavigationIcon() {
Toolbar[] toolbars = getToolbars();
if (toolbars != null) {
Toolbar toolbar = toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX];
Drawable icon = style.getToolbarNavigationIcon();
toolbar.setNavigationIcon(icon);
toolbar.setNavigationOnClickListener(getModel().getToolbarNavigationIconListener());
}
}
代码示例来源:origin: ongakuer/PhotoDraweeView
setContentView(R.layout.activity_shared_element);
((Toolbar) findViewById(R.id.toolbar)).setNavigationOnClickListener(
new View.OnClickListener() {
@Override public void onClick(View v) {
代码示例来源:origin: ongakuer/PhotoDraweeView
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
((Toolbar) findViewById(R.id.toolbar)).setNavigationOnClickListener(
new View.OnClickListener() {
@Override public void onClick(View v) {
onBackPressed();
}
});
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new DraweeAdapter());
}
代码示例来源:origin: ongakuer/PhotoDraweeView
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewpager);
((Toolbar) findViewById(R.id.toolbar)).setNavigationOnClickListener(
new View.OnClickListener() {
@Override public void onClick(View v) {
onBackPressed();
}
});
CircleIndicator indicator = findViewById(R.id.indicator);
MultiTouchViewPager viewPager = findViewById(R.id.view_pager);
viewPager.setAdapter(new DraweePagerAdapter());
indicator.setViewPager(viewPager);
}
代码示例来源:origin: iTXTech/Daedalus
DrawableCompat.setTint(wrappedDrawable, Color.WHITE);
toolbar.setNavigationIcon(drawable);
toolbar.setNavigationOnClickListener(v -> onBackPressed());
toolbar.setOnMenuItemClickListener(fragment);
toolbar.inflateMenu(R.menu.custom_config);
代码示例来源:origin: pR0Ps/LocationShare
private void setToolbar() {
LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
Toolbar toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar, root, false);
root.addView(toolbar, 0);
toolbar.setTitle(R.string.settings);
toolbar.setNavigationOnClickListener(v -> finish());
}
}
代码示例来源:origin: linkedin/shaky-android
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.shaky_toolbar);
EditText messageEditText = (EditText) view.findViewById(R.id.shaky_form_message);
ImageView attachmentImageView = (ImageView) view.findViewById(R.id.shaky_form_attachment);
Uri screenshotUri = getArguments().getParcelable(KEY_SCREENSHOT_URI);
String title = getArguments().getString(KEY_TITLE);
toolbar.setTitle(title);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(createNavigationClickListener());
toolbar.inflateMenu(R.menu.shaky_feedback_activity_actions);
toolbar.setOnMenuItemClickListener(createMenuClickListener(messageEditText));
String hint = getArguments().getString(KEY_HINT);
messageEditText.setHint(hint);
messageEditText.requestFocus();
attachmentImageView.setImageURI(screenshotUri);
attachmentImageView.setOnClickListener(createNavigationClickListener());
}
代码示例来源:origin: LineageOS/android_packages_apps_Jelly
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_back);
toolbar.setNavigationOnClickListener(v -> finish());
}
代码示例来源:origin: pranavpandey/dynamic-support
/**
* Set the icon and on click listener for the back or up button in the app bar.
*
* @param icon The drawable used for the back or up button.
* @param onClickListener The click listener for the back or up button.
*/
public void setNavigationClickListener(@Nullable Drawable icon,
@Nullable View.OnClickListener onClickListener) {
mToolbar.setNavigationIcon(icon);
setSupportActionBar(mToolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setHomeButtonEnabled(onClickListener != null);
}
mToolbar.setNavigationOnClickListener(onClickListener);
}
代码示例来源:origin: AlexMofer/ProjectX
/**
* 设置 Toolbar
*
* @param toolbarId Toolbar资源ID
*/
public final void setSupportActionBar(@IdRes int toolbarId) {
final View view = findViewById(toolbarId);
if (view instanceof Toolbar) {
if (mToolbarListener == null) {
mToolbarListener = new ToolbarNavigationOnClickListener();
}
final Toolbar toolbar = (Toolbar) view;
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(mToolbarListener);
}
}
代码示例来源:origin: morogoku/MTweaks-KernelAdiutorMOD
public void initToolBar() {
Toolbar toolbar = getToolBar();
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> finish());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
代码示例来源:origin: zas023/CocoBill
/**************************used method*******************************************/
protected ActionBar supportActionBar(Toolbar toolbar) {
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mToolbar.setNavigationOnClickListener(
(v) -> finish()
);
return actionBar;
}
}
代码示例来源:origin: linkedin/shaky-android
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
FeedbackTypeAdapter adapter = new FeedbackTypeAdapter(getActivity(), getData());
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.shaky_recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(adapter);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.shaky_toolbar);
toolbar.setTitle(R.string.shaky_feedback_title);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
}
代码示例来源:origin: zas023/CocoBill
@Override
protected void initWidget() {
super.initWidget();
toolbar = findViewById(R.id.toolbar);
changeCL = findViewById(R.id.cil_change);
forgetCL = findViewById(R.id.cil_forget);
storeCL = findViewById(R.id.cil_store);
sortCL = findViewById(R.id.cil_sort);
payCL = findViewById(R.id.cil_pay);
exportCL = findViewById(R.id.cil_export);
//初始化Toolbar
toolbar.setTitle("设置");
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(v -> finish());
storeCL.setRightText(GlideCacheUtil.getInstance().getCacheSize(mContext));
}
内容来源于网络,如有侵权,请联系作者删除!