Java Code Examples for androidx.appcompat.widget.Toolbar#setNavigationIcon()
The following examples show how to use
androidx.appcompat.widget.Toolbar#setNavigationIcon() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DConnectSettingCompatPageFragmentActivity.java From DeviceConnect-Android with MIT License | 6 votes |
/** * ViewPagerを持つレイアウトを自動的に設定する. * サブクラスでオーバーライドする場合は setContentView を<strong>実行しないこと</strong>。 * * @param savedInstanceState パラメータ * @see android.app.Activity#onCreate(Bundle) */ @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting_page); mViewPager = (ViewPager) findViewById(R.id.setting_pager); mViewPager.setAdapter(new DConnectFragmentPagerAdapter(getSupportFragmentManager(), this)); Toolbar toolbar = new Toolbar(this); toolbar.setTitle(org.deviceconnect.android.deviceplugin.chromecast.R.string.activity_setting_page_title); toolbar.setBackgroundColor(Color.parseColor("#00a0e9")); toolbar.setTitleTextColor(Color.parseColor("#FFFFFF")); addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); toolbar.setNavigationIcon(org.deviceconnect.android.deviceplugin.chromecast.R.drawable.close_icon); toolbar.setNavigationOnClickListener((view) -> { finish(); }); setSupportActionBar(toolbar); }
Example 2
Source File: FormFragment.java From shaky-android with Apache License 2.0 | 6 votes |
@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); int sendIconResource = getArguments().getInt(KEY_MENU); String title = getArguments().getString(KEY_TITLE); toolbar.setTitle(title); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(createNavigationClickListener()); toolbar.inflateMenu(sendIconResource); toolbar.setOnMenuItemClickListener(createMenuClickListener(messageEditText)); String hint = getArguments().getString(KEY_HINT); messageEditText.setHint(hint); messageEditText.requestFocus(); attachmentImageView.setImageURI(screenshotUri); attachmentImageView.setOnClickListener(createNavigationClickListener()); }
Example 3
Source File: UCropActivity.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * Configures and styles both status bar and toolbar. */ private void setupAppBar() { setStatusBarColor(mStatusBarColor); final Toolbar toolbar = findViewById(R.id.toolbar); // Set all of the Toolbar coloring toolbar.setBackgroundColor(mToolbarColor); toolbar.setTitleTextColor(mToolbarWidgetColor); final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(mToolbarWidgetColor); toolbarTitle.setText(mToolbarTitle); // Color buttons inside the Toolbar Drawable stateButtonDrawable = AppCompatResources.getDrawable(this, mToolbarCancelDrawable).mutate(); stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(stateButtonDrawable); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); } }
Example 4
Source File: TestNestedViewPagerActivity.java From SmoothRefreshLayout with MIT License | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_with_nested_viewpager); final Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72); toolbar.setNavigationOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); ViewPager viewPager = findViewById(R.id.viewPager_with_nested_pager); List<NestedPageWithSrlFragment> fragments = new ArrayList<>(); for (int color : sColors) { fragments.add(NestedPageWithSrlFragment.newInstance(color)); } ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments); viewPager.setAdapter(adapter); }
Example 5
Source File: SelectFragment.java From shaky-android with Apache License 2.0 | 6 votes |
@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(); } }); }
Example 6
Source File: MenuIntroFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.intro_menu, container, false); Toolbar toolbar = v.findViewById(R.id.toolbar); toolbar.setTitle(R.string.appName); toolbar.setNavigationIcon( MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.MENU).setColorResource(R.color.white) .setToActionbarSize().build()); mDrawerLayout = v.findViewById(R.id.drawer); mDrawerLayout.setBackgroundResource(R.color.background); ListView lv = v.findViewById(R.id.base_nav); lv.setAdapter(buildNavAdapter(getActivity())); return v; }
Example 7
Source File: BrandedActivity.java From nextcloud-notes with GNU General Public License v3.0 | 6 votes |
public void applyBrandToPrimaryToolbar(@NonNull AppBarLayout appBarLayout, @NonNull Toolbar toolbar) { // FIXME Workaround for https://github.com/stefan-niedermann/nextcloud-notes/issues/889 appBarLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.primary)); final Drawable overflowDrawable = toolbar.getOverflowIcon(); if (overflowDrawable != null) { overflowDrawable.setColorFilter(colorAccent, PorterDuff.Mode.SRC_ATOP); toolbar.setOverflowIcon(overflowDrawable); } final Drawable navigationDrawable = toolbar.getNavigationIcon(); if (navigationDrawable != null) { navigationDrawable.setColorFilter(colorAccent, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(navigationDrawable); } }
Example 8
Source File: UCropActivity.java From EasyPhotos with Apache License 2.0 | 6 votes |
/** * Configures and styles both status bar and toolbar. */ private void setupAppBar() { setStatusBarColor(mStatusBarColor); final Toolbar toolbar = findViewById(R.id.toolbar); // Set all of the Toolbar coloring toolbar.setBackgroundColor(mToolbarColor); toolbar.setTitleTextColor(mToolbarWidgetColor); final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(mToolbarWidgetColor); toolbarTitle.setText(mToolbarTitle); // Color buttons inside the Toolbar Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate(); stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(stateButtonDrawable); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); } }
Example 9
Source File: SearchActivity.java From Instagram-Profile-Downloader with MIT License | 6 votes |
private void createToolbar() { Toolbar toolbar = findViewById(R.id.toolbar_search); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); } toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_back_24px)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); SearchActivity.this.overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(false); }
Example 10
Source File: AboutActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
private void initWidget() { this.container = findViewById(R.id.activity_about_container); Toolbar toolbar = findViewById(R.id.activity_about_toolbar); toolbar.setNavigationIcon(R.drawable.ic_toolbar_back); toolbar.setTitle(R.string.action_about); toolbar.setNavigationOnClickListener(this); RecyclerView recyclerView = findViewById(R.id.activity_about_recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(new AboutAdapter(this)); }
Example 11
Source File: CandyBarMainActivity.java From candybar with Apache License 2.0 | 5 votes |
@Override public void onSearchExpanded(boolean expand) { Toolbar toolbar = findViewById(R.id.toolbar); mIsMenuVisible = !expand; if (expand) { int color = ColorHelper.getAttributeColor(this, R.attr.toolbar_icon); toolbar.setNavigationIcon(DrawableHelper.getTintedDrawable( this, R.drawable.ic_toolbar_back, color)); toolbar.setNavigationOnClickListener(view -> onBackPressed()); } else { SoftKeyboardHelper.closeKeyboard(this); ColorHelper.setStatusBarColor(this, Color.TRANSPARENT, true); if (CandyBarApplication.getConfiguration().getNavigationIcon() == CandyBarApplication.NavigationIcon.DEFAULT) { mDrawerToggle.setDrawerArrowDrawable(new DrawerArrowDrawable(this)); } else { toolbar.setNavigationIcon(ConfigurationHelper.getNavigationIcon(this, CandyBarApplication.getConfiguration().getNavigationIcon())); } toolbar.setNavigationOnClickListener(view -> mDrawerLayout.openDrawer(GravityCompat.START)); } mDrawerLayout.setDrawerLockMode(expand ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED); supportInvalidateOptionsMenu(); }
Example 12
Source File: PreviewIconActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
private void initWidget() { this.container = findViewById(R.id.activity_preview_icon_container); Toolbar toolbar = findViewById(R.id.activity_preview_icon_toolbar); toolbar.setTitle(provider.getProviderName()); toolbar.setNavigationIcon(R.drawable.ic_toolbar_back); toolbar.setNavigationOnClickListener(v -> finish()); toolbar.inflateMenu(R.menu.activity_preview_icon); toolbar.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.action_appStore: if (provider instanceof DefaultResourceProvider || provider instanceof PixelResourcesProvider) { IntentHelper.startAppStoreDetailsActivity(this); } else { IntentHelper.startAppStoreDetailsActivity(this, provider.getPackageName()); } break; case R.id.action_about: if (provider instanceof DefaultResourceProvider || provider instanceof PixelResourcesProvider) { IntentHelper.startApplicationDetailsActivity(this); } else { IntentHelper.startApplicationDetailsActivity(this, provider.getPackageName()); } break; } return true; }); RecyclerView recyclerView = findViewById(R.id.activity_preview_icon_recyclerView); GridLayoutManager manager = new GridLayoutManager(this, 4); manager.setSpanSizeLookup(WeatherIconAdapter.getSpanSizeLookup(4, itemList)); recyclerView.setLayoutManager(manager); recyclerView.setAdapter(new WeatherIconAdapter(this, itemList)); }
Example 13
Source File: ConfigIntroFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.intro_config, container, false); Toolbar toolbar = mView.findViewById(R.id.toolbar); toolbar.setTitle(R.string.appName); toolbar.setNavigationIcon(MaterialDrawableBuilder.with(getActivity()) .setIcon(MaterialDrawableBuilder.IconValue.MENU) .setColorResource(R.color.white) .setToActionbarSize() .build()); try { MaterialMenuInflater.with(getActivity(), getActivity().getMenuInflater()) .setDefaultColorResource(R.color.white) .inflate(R.menu.vakit, toolbar.getMenu()); mMenuItem = toolbar.getMenu().getItem(0); mMenuItem.setIcon(mMenuItem.getIcon()); } catch (Exception e) { e.printStackTrace(); Crashlytics.logException(e); } return mView; }
Example 14
Source File: TaskerActivity.java From ShadowsocksRR with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_tasker); profilesAdapter = new ProfilesAdapter(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(R.string.app_name); toolbar.setNavigationIcon(R.drawable.ic_navigation_close); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); taskerOption = TaskerSettings.fromIntent(getIntent()); mSwitch = (Switch) findViewById(R.id.serviceSwitch); mSwitch.setChecked(taskerOption.switchOn); RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList); LinearLayoutManager lm = new LinearLayoutManager(this); profilesList.setLayoutManager(lm); profilesList.setItemAnimator(new DefaultItemAnimator()); profilesList.setAdapter(profilesAdapter); if (taskerOption.profileId >= 0) { int position = 0; List<Profile> profiles = profilesAdapter.profiles; for (int i = 0; i < profiles.size(); i++) { Profile profile = profiles.get(i); if (profile.id == taskerOption.profileId) { position = i + 1; break; } } lm.scrollToPosition(position); } }
Example 15
Source File: AbstractTabSwitcherLayout.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
/** * 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()); } }
Example 16
Source File: SelectProviderActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 4 votes |
private void initToolbar() { Toolbar toolbar = findViewById(R.id.activity_settings_toolbar); toolbar.setTitle(getString(R.string.settings_title_service_provider)); toolbar.setNavigationIcon(R.drawable.ic_toolbar_back); toolbar.setNavigationOnClickListener(view -> finish()); }
Example 17
Source File: IconPickerDialog.java From Status with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_icon_picker); Toolbar toolbar = findViewById(R.id.toolbar); if (title != null) toolbar.setTitle(title); Drawable back = ImageUtils.getVectorDrawable(getContext(), R.drawable.ic_back); DrawableCompat.setTint(back, Color.BLACK); toolbar.setNavigationIcon(back); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isShowing()) dismiss(); } }); recycler = findViewById(R.id.recycler); recycler.setLayoutManager(new GridLayoutManager(getContext(), 1)); adapter = new IconStyleAdapter(getContext(), icon, styles, this); adapter.setIconStyle(getPreference()); recycler.setAdapter(adapter); findViewById(R.id.add).setOnClickListener(view -> { String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; if (!StaticUtils.isPermissionsGranted(getContext(), permissions)) { if (getOwnerActivity() != null) StaticUtils.requestPermissions(getOwnerActivity(), permissions); else if (getContext() instanceof Activity) StaticUtils.requestPermissions((Activity) getContext(), permissions); else Toast.makeText(getContext(), R.string.msg_missing_storage_permission, Toast.LENGTH_SHORT).show(); } else { new IconCreatorDialog( getContext(), styles.get(0).getSize(), (String[]) PreferenceData.ICON_ICON_STYLE_NAMES.getSpecificValue(getContext(), icon.getIdentifierArgs()), icon.getIconNames()).setListener(style -> { icon.addIconStyle(style); styles = icon.getIconStyles(); adapter = new IconStyleAdapter(getContext(), icon, styles, IconPickerDialog.this); adapter.setIconStyle(style); setPreference(style); recycler.setAdapter(adapter); }) .show(); } }); findViewById(R.id.cancel).setOnClickListener(view -> cancel()); findViewById(R.id.confirm).setOnClickListener(view -> confirm()); }
Example 18
Source File: BaseActivity.java From CrazyDaily with Apache License 2.0 | 4 votes |
protected void showBack(Toolbar toolbar) { toolbar.setNavigationIcon(R.mipmap.ic_back); toolbar.setNavigationOnClickListener(v -> finish()); }
Example 19
Source File: BaseFragment.java From CrazyDaily with Apache License 2.0 | 4 votes |
protected void showBack(Toolbar toolbar) { toolbar.setNavigationIcon(R.mipmap.ic_back); toolbar.setNavigationOnClickListener(v -> mActivity.finish()); }
Example 20
Source File: CardDisplayManageActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_card_display_manage); Toolbar toolbar = findViewById(R.id.activity_card_display_manage_toolbar); toolbar.setNavigationIcon(R.drawable.ic_toolbar_back); toolbar.setNavigationOnClickListener(view -> finish()); List<CardDisplay> displayCards = SettingsOptionManager.getInstance(this).getCardDisplayList(); cardDisplayAdapter = new CardDisplayAdapter(displayCards, cardDisplay -> { setResult(RESULT_OK); tagAdapter.insertItem(new CardTag(cardDisplay)); resetBottomBarVisibility(); }); RecyclerView recyclerView = findViewById(R.id.activity_card_display_manage_recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.addItemDecoration(new ListDecoration(this)); recyclerView.setAdapter(cardDisplayAdapter); new ItemTouchHelper( new CardDisplaySwipeCallback( ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT ) ).attachToRecyclerView(recyclerView); List<CardDisplay> otherCards = new ArrayList<>(); otherCards.add(CardDisplay.CARD_DAILY_OVERVIEW); otherCards.add(CardDisplay.CARD_HOURLY_OVERVIEW); otherCards.add(CardDisplay.CARD_AIR_QUALITY); otherCards.add(CardDisplay.CARD_ALLERGEN); otherCards.add(CardDisplay.CARD_SUNRISE_SUNSET); otherCards.add(CardDisplay.CARD_LIFE_DETAILS); for (int i = otherCards.size() - 1; i >= 0; i --) { for (int j = 0; j < displayCards.size(); j ++) { if (otherCards.get(i) == displayCards.get(j)) { otherCards.remove(i); break; } } } List<TagAdapter.Tag> tagList = new ArrayList<>(); for (CardDisplay card : otherCards) { tagList.add(new CardTag(card)); } tagAdapter = new TagAdapter(this, tagList, (checked, oldPosition, newPosition) -> { setResult(RESULT_OK); CardTag tag = (CardTag) tagAdapter.removeItem(newPosition); cardDisplayAdapter.insertItem(tag.card); resetBottomBarVisibility(); return true; }); bottomBar = findViewById(R.id.activity_card_display_manage_bottomBar); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { bottomBar.setOnApplyWindowInsetsListener((v, insets) -> { bottomBar.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); return insets; }); } RecyclerView bottomRecyclerView = findViewById(R.id.activity_card_display_manage_bottomRecyclerView); bottomRecyclerView.setLayoutManager( new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)); bottomRecyclerView.addItemDecoration( new GridMarginsDecoration( getResources().getDimension(R.dimen.normal_margin), bottomRecyclerView ) ); bottomRecyclerView.setAdapter(tagAdapter); bottomAnimator = null; bottomBarVisibility = false; bottomRecyclerView.post(this::resetBottomBarVisibility); }