Java Code Examples for androidx.appcompat.app.ActionBar#setSubtitle()

The following examples show how to use androidx.appcompat.app.ActionBar#setSubtitle() . 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: FragmentBase.java    From FairEmail with GNU General Public License v3.0 6 votes vote down vote up
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 2
Source File: TableListFragment.java    From android_dbinspector with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: ProjectActivity.java    From intra42 with Apache License 2.0 5 votes vote down vote up
@Override
public String getToolbarName() {
    if (projectUser != null && projectUser.project != null) {
        if (!projectUser.project.isMaster()) {
            ActionBar actionBar = super.getSupportActionBar();
            if (actionBar != null)
                actionBar.setSubtitle(projectUser.project.parent.name);
        }
        return projectUser.project.name;
    } else if (slugProject != null)
        return slugProject;
    return null;
}
 
Example 4
Source File: ClaimExperimentsActivity.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_claim_experiments);
  boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
  if (!isTablet) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }

  AppAccount claimingAccount =
      WhistlePunkApplication.getAccount(this, getIntent(), ARG_ACCOUNT_KEY);

  ActionBar actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(
      ColorUtils.colorDrawable(
          this,
          ContextCompat.getDrawable(this, R.drawable.ic_close_white_24dp),
          R.color.claim_experiments_action_bar_text));
  actionBar.setHomeActionContentDescription(android.R.string.cancel);
  actionBar.setTitle(getString(R.string.title_activity_claim_experiments));
  actionBar.setSubtitle(claimingAccount.getAccountName());

  if (getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null) {
    Fragment fragment =
        ExperimentListFragment.newInstanceForClaimExperimentsMode(
            this, claimingAccount, getIntent().getBooleanExtra(ARG_USE_PANES, true));
    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.container, fragment, FRAGMENT_TAG)
        .commit();
  }
}
 
Example 5
Source File: TalkBackPreferencesActivity.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // Shows TalkBack's abbreviated version number in the action bar,
  ActionBar actionBar = getSupportActionBar();
  PackageInfo packageInfo = TalkBackPreferenceFragment.getPackageInfo(this);
  if (actionBar != null && packageInfo != null) {
    actionBar.setSubtitle(
        getString(R.string.talkback_preferences_subtitle, packageInfo.versionName));
  }
}
 
Example 6
Source File: BaseFragment.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
protected void setActionBarSubtitle(CharSequence title) {
    if (getActivity() != null) {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        String t = Utils.nullToText(title);
        if (actionBar != null && !t.equals(actionBar.getTitle())) {
            actionBar.setSubtitle(t);
        }
    }
}
 
Example 7
Source File: WiFiSwitchOn.java    From WiFiAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
private void applyToActionBar(@NonNull MainActivity mainActivity) {
    ActionBar actionBar = mainActivity.getSupportActionBar();
    if (actionBar != null) {
        int colorSelected = ContextCompat.getColor(mainActivity, R.color.selected);
        int colorNotSelected = ContextCompat.getColor(mainActivity, R.color.regular);
        Resources resources = mainActivity.getResources();
        String wiFiBand2 = resources.getString(WiFiBand.GHZ2.getTextResource());
        String wiFiBand5 = resources.getString(WiFiBand.GHZ5.getTextResource());
        WiFiBand wiFiBand = MainContext.INSTANCE.getSettings().getWiFiBand();
        String subtitle = makeSubtitle(WiFiBand.GHZ2.equals(wiFiBand), wiFiBand2, wiFiBand5, colorSelected, colorNotSelected);
        actionBar.setSubtitle(TextUtils.fromHtml(subtitle));
    }
}
 
Example 8
Source File: TableListFragment.java    From android_dbinspector with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroyView() {
    super.onDestroyView();

    try {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        actionBar.setSubtitle("");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 9
Source File: LauncherActivity.java    From Android-Plugin-Framework with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	EventBus.getDefault().register(this);
       //测试databinding
	//PluginLauncherBinding bing =  DataBindingUtil.setContentView(this, R.layout.plugin_launcher);
	//DataBindingTestVO dataBindingTestVO = new DataBindingTestVO("DataBind:打开PluginHellWorld");
	//bing.setTest(dataBindingTestVO);

	setContentView(R.layout.plugin_launcher);
       ButterKnifeCompat.bind(this);

	testLog();

       fakeThisForUmengSdk = fakeActivityForUMengSdk(LauncherActivity.this);

       requestPermission();

	ActionBar actionBar = getSupportActionBar();
	actionBar.setTitle("这是插件首屏");
	actionBar.setSubtitle("这是副标题");
	actionBar.setLogo(R.drawable.ic_launcher);
	actionBar.setIcon(R.drawable.ic_launcher);
	actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP
			| ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);

	findViewById( R.id.onClickHellowrld).setOnClickListener(this);
	findViewById( R.id.onClickPluginNormalFragment).setOnClickListener(this);
	findViewById( R.id.onClickPluginSpecFragment).setOnClickListener(this);
	findViewById( R.id.onClickPluginForDialogActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginForOppoAndVivoActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginNotInManifestActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginFragmentTestActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginSingleTaskActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestOpenPluginActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestTabActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginWebViewActivity).setOnClickListener(this);
	findViewById( R.id.onClickTransparentActivity).setOnClickListener(this);
	findViewById( R.id.onClickDesignActivity).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestReceiver).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestReceiver2).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestService).setOnClickListener(this);
	findViewById( R.id.onClickPluginTestService2).setOnClickListener(this);
	findViewById( R.id.onTestFileProvider).setOnClickListener(this);

       testQueryIntentActivities();
       testAlarm();
       testService();
       testMeta();
       testVersion1();
       testVersion2();
	testMuliDex();
	testUseLibray();
}
 
Example 10
Source File: WiFiSwitchOff.java    From WiFiAnalyzer with GNU General Public License v3.0 4 votes vote down vote up
private void applyToActionBar(@NonNull MainActivity mainActivity) {
    ActionBar actionBar = mainActivity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(StringUtils.EMPTY);
    }
}
 
Example 11
Source File: NavigationDrawerFragment.java    From bitmask_android with GNU General Public License v3.0 4 votes vote down vote up
private void setActionBarTitle(@StringRes int resId) {
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(resId);
    }
}
 
Example 12
Source File: NavigationDrawerFragment.java    From bitmask_android with GNU General Public License v3.0 4 votes vote down vote up
private void hideActionBarSubTitle() {
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(null);
    }
}
 
Example 13
Source File: MainActivity.java    From bitmask_android with GNU General Public License v3.0 4 votes vote down vote up
private void hideActionBarSubTitle() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(null);
    }
}
 
Example 14
Source File: MainActivity.java    From bitmask_android with GNU General Public License v3.0 4 votes vote down vote up
private void setActionBarTitle(@StringRes int stringId) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(stringId);
    }
}