Java Code Examples for androidx.appcompat.widget.Toolbar#setNavigationOnClickListener()
The following examples show how to use
androidx.appcompat.widget.Toolbar#setNavigationOnClickListener() .
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: ActivatedPinPreferenceFragment.java From Hentoid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_pin_preference_on, container, false); Toolbar toolbar = requireViewById(rootView, R.id.toolbar); toolbar.setNavigationOnClickListener(v -> requireActivity().finish()); offSwitch = requireViewById(rootView, R.id.switch_off); offSwitch.setOnClickListener(v -> onOffClick()); boolean lockOnAppRestoredEnabled = Preferences.isLockOnAppRestore(); Switch lockOnAppRestored = requireViewById(rootView, R.id.switch_lock_on_restore); lockOnAppRestored.setChecked(lockOnAppRestoredEnabled); lockOnAppRestored.setOnCheckedChangeListener((b, v) -> onLockOnAppRestoreClick(v)); int lockTimer = Preferences.getLockTimer(); lockDelaySpinner = requireViewById(rootView, R.id.lock_timer); lockDelaySpinner.setVisibility(lockOnAppRestoredEnabled ? View.VISIBLE : View.GONE); lockDelaySpinner.setSelection(lockTimer); lockDelaySpinner.setOnItemSelectedListener(this); View resetButton = requireViewById(rootView, R.id.text_reset_pin); resetButton.setOnClickListener(v -> onResetClick()); return rootView; }
Example 2
Source File: FlexibleSpaceExampleActivity.java From CoordinatorExamples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flexible_space); mFab = findViewById(R.id.flexible_example_fab); Toolbar toolbar = (Toolbar) findViewById(R.id.flexible_example_toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); AppBarLayout appbar = (AppBarLayout) findViewById(R.id.flexible_example_appbar); appbar.addOnOffsetChangedListener(this); }
Example 3
Source File: AccPersonalFragment.java From tindroid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return null; } // Inflate the fragment layout View fragment = inflater.inflate(R.layout.fragment_acc_personal, container, false); final ActionBar bar = activity.getSupportActionBar(); if (bar != null) { bar.setDisplayHomeAsUpEnabled(true); } Toolbar toolbar = activity.findViewById(R.id.toolbar); toolbar.setTitle(R.string.general); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { activity.getSupportFragmentManager().popBackStack(); } }); return fragment; }
Example 4
Source File: ScannerActivity.java From Maying with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_scanner); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(getTitle()); toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { navigateUp(); } }); scannerView = (ZXingScannerView) findViewById(R.id.scanner); if (Build.VERSION.SDK_INT >= 25) { ShortcutManager service = getSystemService(ShortcutManager.class); if (service != null) { service.reportShortcutUsed("scan"); } } }
Example 5
Source File: ProfileManagerActivity.java From ShadowsocksRR with Apache License 2.0 | 6 votes |
/** * init toolbar */ private void initToolbar() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(R.string.profiles); toolbar.setNavigationIcon(R.drawable.ic_navigation_close); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = getParentActivityIntent(); if (shouldUpRecreateTask(intent) || isTaskRoot()) { TaskStackBuilder.create(ProfileManagerActivity.this).addNextIntentWithParentStack(intent).startActivities(); } else { finish(); } } }); toolbar.inflateMenu(R.menu.profile_manager_menu); toolbar.setOnMenuItemClickListener(this); }
Example 6
Source File: PreferenceActivity.java From MaterialPreferenceLibrary with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mpl__preference_activity); _toolbar = (Toolbar) findViewById(R.id.abp__toolbar); if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { View shadowView = findViewById(R.id.abp__shadowView); final ViewGroup parent = (ViewGroup) shadowView.getParent(); parent.removeView(shadowView); } addPreferencesFromResource(getPreferencesXmlId()); final Map<Preference, PreferenceGroup> preferenceToParentMap = buildPreferenceParentTree(this); for (PreferenceGroup preferenceGroup : preferenceToParentMap.values()) if (preferenceGroup instanceof PreferenceScreen) preferenceGroup.setLayoutResource(R.layout.mpl__preference); _toolbar.setClickable(true); _toolbar.setNavigationIcon(getResIdFromAttribute(this, R.attr.homeAsUpIndicator)); _toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { finish(); } }); _toolbar.setTitle(getTitle()); }
Example 7
Source File: CreatePinDialogFragment.java From natrium-android-wallet with BSD 2-Clause "Simplified" License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // init dependency injection if (getActivity() instanceof ActivityWithComponent) { ((ActivityWithComponent) getActivity()).getActivityComponent().inject(this); } firstPin = null; // inflate the view binding = DataBindingUtil.inflate( inflater, R.layout.fragment_create_pin, container, false); view = binding.getRoot(); binding.setHandlers(new ClickHandlers()); binding.pinLockView.attachIndicatorDots(binding.pinIndicatorDots); binding.pinLockView.setPinLockListener(pinLockListener); binding.pinLockView.setPinLength(PIN_LENGTH); binding.pinSubtitle.setText(("")); // set the listener for Navigation Toolbar toolbar = view.findViewById(R.id.dialog_appbar); if (toolbar != null) { final CreatePinDialogFragment window = this; toolbar.setNavigationOnClickListener(v1 -> window.dismiss()); } return view; }
Example 8
Source File: MediaPickerFolderFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void initToolbar(Toolbar toolbar) { ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar); ((AppCompatActivity) requireActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(toolbarTitle); toolbar.setNavigationOnClickListener(v -> requireActivity().onBackPressed()); }
Example 9
Source File: MediaPickerItemFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void initToolbar(Toolbar toolbar) { ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar); ((AppCompatActivity) requireActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(folderTitle); toolbar.setNavigationOnClickListener(v -> requireActivity().onBackPressed()); }
Example 10
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 11
Source File: BaseFragment.java From TwistyTimer with GNU General Public License v3.0 | 5 votes |
/** * This function should be called in every fragment that needs a toolbar * Every fragment has its own toolbar, and this function executes the * necessary steps to ensure the toolbar is correctly bound to the main * activity, which handles the rest (drawer and options menu) * <p/> * Also, a warning: always bind the toolbar title BEFORE calling this function * otherwise, it won't work. * * @param toolbar The toolbar present in the fragment */ protected void setupToolbarForFragment(Toolbar toolbar) { toolbar.setNavigationIcon(R.drawable.ic_outline_settings_24px); toolbar.getNavigationIcon().setColorFilter(ThemeUtils.fetchAttrColor(getContext(), R.attr.colorTimerText), PorterDuff.Mode.SRC_IN); getMainActivity().setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getMainActivity().openDrawer(); } }); }
Example 12
Source File: BoxBrowseActivity.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
/** * Helper method to initialize the activity with the default toolbar for the Share SDK. * This will show a material themed toolbar with a back button that will finish the Activity. */ protected void initToolbar() { Toolbar actionBar = (Toolbar) findViewById(com.box.androidsdk.browse.R.id.box_action_bar); setSupportActionBar(actionBar); actionBar.setNavigationIcon(com.box.androidsdk.browse.R.drawable.ic_box_browsesdk_arrow_back_grey_24dp); actionBar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.box_browsesdk_fragment_container); if (fragment instanceof BoxSearchFragment) { onBackPressed(); return; } if (mSearchView.isExpanded()) { clearSearch(); return; } FragmentManager fragManager = getSupportFragmentManager(); if (fragManager != null && fragManager.getBackStackEntryCount() > 0) { getSupportFragmentManager().popBackStack(); } else { finish(); } } }); }
Example 13
Source File: SettingsActivity.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
private void initToolbar() { Toolbar toolbar = findViewById(R.id.activity_settings_toolbar); toolbar.setTitle(getString(R.string.action_settings)); toolbar.setNavigationIcon(R.drawable.ic_toolbar_back); toolbar.setNavigationOnClickListener(view -> finish()); toolbar.inflateMenu(R.menu.activity_settings); toolbar.setOnMenuItemClickListener(this); }
Example 14
Source File: BaseActivity.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 设置 Toolbar * * @param toolbarId Toolbar资源ID */ public final void setSupportActionBar(@IdRes int toolbarId) { final View view = findViewById(toolbarId); if (view instanceof Toolbar) { final Toolbar toolbar = (Toolbar) view; setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(this::onToolbarNavigationClick); } }
Example 15
Source File: PinDialogFragment.java From natrium-android-wallet with BSD 2-Clause "Simplified" License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // init dependency injection if (getActivity() instanceof ActivityWithComponent) { ((ActivityWithComponent) getActivity()).getActivityComponent().inject(this); } // inflate the view binding = DataBindingUtil.inflate( inflater, R.layout.fragment_pin, container, false); view = binding.getRoot(); binding.setHandlers(new ClickHandlers()); binding.pinLockView.attachIndicatorDots(binding.pinIndicatorDots); binding.pinLockView.setPinLockListener(pinLockListener); binding.pinLockView.setPinLength(PIN_LENGTH); if (subtitle != null) { binding.pinSubtitle.setText(subtitle); } else { binding.pinSubtitle.setText(("")); } // set the listener for Navigation Toolbar toolbar = view.findViewById(R.id.dialog_appbar); if (toolbar != null) { final PinDialogFragment window = this; toolbar.setNavigationOnClickListener(v1 -> window.dismiss()); } return view; }
Example 16
Source File: ModulesBookmark.java From EdXposedManager with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ThemeUtil.setTheme(this); setContentView(R.layout.activity_container); mRepoLoader = RepoLoader.getInstance(); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(view -> finish()); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setTitle(R.string.bookmarks); ab.setDisplayHomeAsUpEnabled(true); } setFloating(toolbar, 0); container = findViewById(R.id.container); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().add(R.id.container, new ModulesBookmarkFragment()).commit(); } }
Example 17
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 18
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 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: SearchActivity.java From Hentoid with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); List<Attribute> preSelectedAttributes = null; if (intent != null && intent.getExtras() != null) { SearchActivityBundle.Parser parser = new SearchActivityBundle.Parser(intent.getExtras()); Uri searchUri = parser.getUri(); if (searchUri != null) preSelectedAttributes = SearchActivityBundle.Parser.parseSearchUri(searchUri); } setContentView(R.layout.activity_search); Toolbar toolbar = findViewById(R.id.search_toolbar); toolbar.setNavigationOnClickListener(v -> onBackPressed()); startCaption = findViewById(R.id.startCaption); // Attribute type buttons TextView anyTypeButton = findViewById(R.id.textCategoryAny); anyTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.TAG, AttributeType.ARTIST, AttributeType.CIRCLE, AttributeType.SERIE, AttributeType.CHARACTER, AttributeType.LANGUAGE)); // Everything but source ! anyTypeButton.setEnabled(true); tagTypeButton = findViewById(R.id.textCategoryTag); tagTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.TAG)); artistTypeButton = findViewById(R.id.textCategoryArtist); artistTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.ARTIST, AttributeType.CIRCLE)); seriesTypeButton = findViewById(R.id.textCategorySeries); seriesTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.SERIE)); characterTypeButton = findViewById(R.id.textCategoryCharacter); characterTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.CHARACTER)); languageTypeButton = findViewById(R.id.textCategoryLanguage); languageTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.LANGUAGE)); sourceTypeButton = findViewById(R.id.textCategorySource); sourceTypeButton.setOnClickListener(v -> onAttrButtonClick(AttributeType.SOURCE)); searchTags = findViewById(R.id.search_tags); LinearLayoutManager llm = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); searchTags.setLayoutManager(llm); selectedAttributeAdapter = new SelectedAttributeAdapter(); selectedAttributeAdapter.setOnClickListener(this::onSelectedAttributeClick); selectedAttributeAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { // Auto-Scroll to last added item @Override public void onItemRangeInserted(int positionStart, int itemCount) { llm.smoothScrollToPosition(searchTags, null, selectedAttributeAdapter.getItemCount()); } }); searchTags.setAdapter(selectedAttributeAdapter); searchButton = findViewById(R.id.search_fab); searchButton.setOnClickListener(v -> searchBooks()); ViewModelFactory vmFactory = new ViewModelFactory(getApplication()); viewModel = new ViewModelProvider(this, vmFactory).get(SearchViewModel.class); viewModel.getAttributesCountData().observe(this, this::onQueryUpdated); viewModel.getSelectedAttributesData().observe(this, this::onSelectedAttributesChanged); viewModel.getSelectedContentCount().observe(this, this::onBooksCounted); if (preSelectedAttributes != null) viewModel.setSelectedAttributes(preSelectedAttributes); else viewModel.update(); }