Java Code Examples for androidx.appcompat.app.AppCompatActivity#getSupportActionBar()
The following examples show how to use
androidx.appcompat.app.AppCompatActivity#getSupportActionBar() .
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: ExperimentDetailsFragment.java From science-journal with Apache License 2.0 | 6 votes |
private void setHomeButtonState(boolean disabled) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { if (claimExperimentsMode) { actionBar.setHomeAsUpIndicator( ContextCompat.getDrawable(activity, R.drawable.ic_close_white_24dp)); } else { final Drawable upArrow = ContextCompat.getDrawable(activity, R.drawable.ic_arrow_back_white_24dp); if (disabled) { upArrow.setAlpha(getResources().getInteger(R.integer.home_disabled_drawable_alpha)); } else { upArrow.setAlpha(getResources().getInteger(R.integer.home_enabled_drawable_alpha)); } actionBar.setHomeAsUpIndicator(upArrow); } } } }
Example 2
Source File: SignUpFragment.java From tindroid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(false); AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return null; } ActionBar bar = activity.getSupportActionBar(); if (bar != null) { bar.setDisplayHomeAsUpEnabled(true); bar.setTitle(R.string.sign_up); } View fragment = inflater.inflate(R.layout.fragment_signup, container, false); fragment.findViewById(R.id.signUp).setOnClickListener(this); return fragment; }
Example 3
Source File: LoginSettingsFragment.java From tindroid with Apache License 2.0 | 6 votes |
@Override public void onCreatePreferences(Bundle bundle, String rootKey) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity == null) { return; } setHasOptionsMenu(false); ActionBar bar = activity.getSupportActionBar(); if (bar != null) { bar.setDisplayHomeAsUpEnabled(true); bar.setHomeButtonEnabled(true); bar.setTitle(R.string.settings); } addPreferencesFromResource(R.xml.login_preferences); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); onSharedPreferenceChanged(sharedPreferences, "pref_hostName"); onSharedPreferenceChanged(sharedPreferences, "pref_useTLS"); onSharedPreferenceChanged(sharedPreferences, "pref_wireTransport"); }
Example 4
Source File: FragmentBase.java From FairEmail with GNU General Public License v3.0 | 6 votes |
private void updateSubtitle() { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null && !isPane()) { ActionBar actionbar = activity.getSupportActionBar(); if (actionbar != null) if ((actionbar.getDisplayOptions() & DISPLAY_SHOW_CUSTOM) == 0) { actionbar.setTitle(title == null ? getString(R.string.app_name) : title); actionbar.setSubtitle(subtitle); } else { View custom = actionbar.getCustomView(); TextView tvTitle = custom.findViewById(R.id.title); TextView tvSubtitle = custom.findViewById(R.id.subtitle); tvTitle.setText(title == null ? getString(R.string.app_name) : title); tvSubtitle.setText(subtitle); } } }
Example 5
Source File: TableListFragment.java From android_dbinspector with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); List<String> tableList = DatabaseHelper.getAllTables(database); String version = DatabaseHelper.getVersion(database); ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(database.getName()); if (!TextUtils.isEmpty(version)) { actionBar.setSubtitle("v" + version); } actionBar.setDisplayHomeAsUpEnabled(true); } adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, tableList); setListAdapter(adapter); getListView().setOnItemClickListener(tableClickListener); }
Example 6
Source File: RecentAppsFragment.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setTitle(R.string.tb_pref_header_recent_apps); ActionBar actionBar = activity.getSupportActionBar(); if(actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true); }
Example 7
Source File: SettingsFragment.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); context = getContext(); toolbar = view.findViewById(R.id.toolbar); final AppCompatActivity parentActivity = (AppCompatActivity) getActivity(); if (toolbar != null) { parentActivity.setSupportActionBar(toolbar); toolbar.setTitle(R.string.settings_title_settings); toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed()); ActionBar supportActionBar = parentActivity.getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); } } setAdultContentViews(); excludedUpdates = findPreference(EXCLUDED_UPDATES_PREFERENCE_KEY); sendFeedback = findPreference(SEND_FEEDBACK_PREFERENCE_KEY); setGDPR(); setupAppTheme(); deleteAccount = findPreference(DELETE_ACCOUNT); socialCampaignNotifications = (SwitchPreferenceCompat) findPreference(CAMPAIGN_SOCIAL_NOTIFICATIONS_PREFERENCE_VIEW_KEY); fileMaxCachePreferenceView = findPreference(MAX_FILE_CACHE); setupClickHandlers(); }
Example 8
Source File: AboutFragment.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setTitle(((MainActivity) getActivity()).getAboutFragmentTitle()); ActionBar actionBar = activity.getSupportActionBar(); if(actionBar != null) actionBar.setDisplayHomeAsUpEnabled(((MainActivity) getActivity()).getAboutFragmentBackArrow()); }
Example 9
Source File: ManageAppDataFragment.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setTitle(R.string.tb_manage_app_data); ActionBar actionBar = activity.getSupportActionBar(); if(actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true); }
Example 10
Source File: FragmentEx.java From SkyTube with GNU General Public License v3.0 | 5 votes |
/** * @return Instance of {@link ActionBar}. */ protected ActionBar getSupportActionBar() { // The Fragment might not always get completely destroyed after Activity.finish(), hence // this code might get called after the hosting activity is destroyed. Therefore we need // to handle getActivity() properly. Refer to: http://stackoverflow.com/a/21886594/3132935 AppCompatActivity activity = getAppCompatActivity(); return (activity != null ? activity.getSupportActionBar() : null); }
Example 11
Source File: CropRotateFragment.java From cloudinary_android with MIT License | 5 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { Toolbar toolbar = getActivity().findViewById(R.id.cropRotateToolbar); activity.setSupportActionBar(toolbar); ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } } }
Example 12
Source File: FreeformModeFragment.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setTitle(R.string.tb_pref_header_freeform); ActionBar actionBar = activity.getSupportActionBar(); if(actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true); }
Example 13
Source File: BaseFragment.java From Jockey with Apache License 2.0 | 5 votes |
@Nullable protected ActionBar getActivitySupportActionBar() { Activity hostingActivity = getActivity(); if (hostingActivity instanceof AppCompatActivity) { AppCompatActivity activity = (AppCompatActivity) hostingActivity; return activity.getSupportActionBar(); } else { return null; } }
Example 14
Source File: HoneycombUtil.java From shortyz with GNU General Public License v3.0 | 5 votes |
public View onActionBarCustom(AppCompatActivity a, int id) { ActionBar bar = a.getSupportActionBar(); if(bar == null){ return null; } bar.setDisplayShowCustomEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setDisplayShowHomeEnabled(true); bar.setCustomView(id); return bar.getCustomView(); }
Example 15
Source File: CommonUtil.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
@SuppressLint("RestrictedApi") public static void hideSupportActionBar(Context context, boolean actionBar, boolean statusBar) { if (actionBar) { AppCompatActivity appCompatActivity = CommonUtil.getAppCompActivity(context); if (appCompatActivity != null) { ActionBar ab = appCompatActivity.getSupportActionBar(); if (ab != null) { ab.setShowHideAnimationEnabled(false); ab.hide(); } } } if (statusBar) { if (context instanceof FragmentActivity) { FragmentActivity fragmentActivity = (FragmentActivity) context; fragmentActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else if (context instanceof Activity) { Activity activity = (Activity) context; activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { CommonUtil.getAppCompActivity(context).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } } }
Example 16
Source File: AboutFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 5 votes |
protected void setActionBarTitle(int titleStringId) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(titleStringId); actionBar.setDisplayHomeAsUpEnabled(true); } } }
Example 17
Source File: ControllerColorPickerFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(R.string.colorpicker_title); actionBar.setDisplayHomeAsUpEnabled(true); } } }
Example 18
Source File: HoneycombUtil.java From shortyz with GNU General Public License v3.0 | 5 votes |
public void hideTitleOnPortrait(AppCompatActivity a) { if(a.getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT){ return; } ActionBar bar = a.getSupportActionBar(); if (bar != null) { bar.setDisplayShowTitleEnabled(false); } }
Example 19
Source File: TutorialMainFragment.java From talkback with Apache License 2.0 | 5 votes |
@Override public void onResume() { super.onResume(); // show general tutorial title, no up arrow AppCompatActivity activity = (AppCompatActivity) getActivity(); ActionBar actionBar = (activity == null) ? null : activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(R.string.tutorial_title); actionBar.setDisplayHomeAsUpEnabled(navigationUpFlag); } }
Example 20
Source File: ControllerPadFragment.java From Bluefruit_LE_Connect_Android_V2 with MIT License | 4 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Set title AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(R.string.controlpad_title); actionBar.setDisplayHomeAsUpEnabled(true); } } // UI mRootLayout = view.findViewById(R.id.rootLayout); mTopSpacerView = view.findViewById(R.id.topSpacerView); mBottomSpacerView = view.findViewById(R.id.bottomSpacerView); mContentView = view.findViewById(R.id.contentView); mBufferTextView = view.findViewById(R.id.bufferTextView); if (mBufferTextView != null) { mBufferTextView.setKeyListener(null); // make it not editable } ImageButton upArrowImageButton = view.findViewById(R.id.upArrowImageButton); upArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton leftArrowImageButton = view.findViewById(R.id.leftArrowImageButton); leftArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton rightArrowImageButton = view.findViewById(R.id.rightArrowImageButton); rightArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton bottomArrowImageButton = view.findViewById(R.id.bottomArrowImageButton); bottomArrowImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button1ImageButton = view.findViewById(R.id.button1ImageButton); button1ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button2ImageButton = view.findViewById(R.id.button2ImageButton); button2ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button3ImageButton = view.findViewById(R.id.button3ImageButton); button3ImageButton.setOnTouchListener(mPadButtonTouchListener); ImageButton button4ImageButton = view.findViewById(R.id.button4ImageButton); button4ImageButton.setOnTouchListener(mPadButtonTouchListener); // Read shared preferences maxPacketsToPaintAsText = UartBaseFragment.kDefaultMaxPacketsToPaintAsText; //PreferencesFragment.getUartTextMaxPackets(this); }