Java Code Examples for android.support.v7.app.ActionBar#setTitle()

The following examples show how to use android.support.v7.app.ActionBar#setTitle() . 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: ActivityHelper.java    From android-atleap with Apache License 2.0 6 votes vote down vote up
/**
 * Change title in the Action Bar
 * @param activity activity
 * @param title title of Action Bar
 * @param typefaceName the full path to font in the assets
 */
public static void changeActionBarTitle(Activity activity, String title, String typefaceName) {
    if (activity == null)
        return;

    if (!(activity instanceof ActionBarActivity))
        return;

    ActionBar actionBar = ((ActionBarActivity) activity).getSupportActionBar();
    if (actionBar != null) {
        if (title != null) {
            if (!TextUtils.isEmpty(typefaceName)) {
                SpannableString spannableTitle = new SpannableString(title);
                spannableTitle.setSpan(new TypefaceSpan(activity, typefaceName), 0, spannableTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                actionBar.setTitle(spannableTitle);
            } else {
                actionBar.setTitle(title);
            }
        }
    }
}
 
Example 2
Source File: MainActivity.java    From KA27 with Apache License 2.0 6 votes vote down vote up
/**
 * Gets called when there is an input on the navigation drawer
 *
 * @param position position of the fragment
 */
private void selectItem(int position) {
    Fragment fragment = VISIBLE_ITEMS.get(position).getFragment();

    if (mScrimInsetsFrameLayout != null) mDrawerLayout.closeDrawer(mScrimInsetsFrameLayout);
    if (fragment == null || cur_position == position) return;
    cur_position = position;

    try {
        getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commitAllowingStateLoss();
    } catch (Exception e) {
        e.printStackTrace();
    }

    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setTitle(VISIBLE_ITEMS.get(position).getTitle());
    mAdapter.setItemChecked(position, true);
}
 
Example 3
Source File: BaseFragmentActivity.java    From base_app_android with Apache License 2.0 6 votes vote down vote up
private void configureToolbar(Toolbar toolbar, @Nullable AppBarLayout appBarLayout) {
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    boolean showToolbar = Behaviour.SHOW_TOOLBAR_AS_DEFAULT;

    if (actionBar != null) {
        Bundle bundle = getIntent().getExtras();

        if (bundle != null) {
            boolean showBackKey = bundle.getBoolean(Behaviour.SHOW_BACK_KEY, Behaviour.SHOW_BACK_AS_DEFAULT);
            showToolbar = bundle.getBoolean(Behaviour.SHOW_TOOLBAR, showToolbar);
            actionBar.setDisplayHomeAsUpEnabled(showBackKey);
            String title = bundle.getString(Behaviour.TITLE_KEY);
            actionBar.setTitle(title);
        } else {
            actionBar.setDisplayHomeAsUpEnabled(Behaviour.SHOW_BACK_AS_DEFAULT);
            actionBar.setTitle(app_name);
        }
    }

    setStatusBarColor();

    if (appBarLayout != null)
        appBarLayout.setVisibility(showToolbar ? View.VISIBLE : View.GONE);
}
 
Example 4
Source File: AddGroupActivity.java    From Social with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_group_activity_layout);

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case OkhttpUtil.MESSAGE_ADD_GROUP:
                    handleAddGroup(msg);
                    break;
            }
        }
    };

    ActionBar actionBar = getSupportActionBar();
    actionBar.setLogo(R.mipmap.ic_arrow_back_white_24dp);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("新建群组");

    initData();

}
 
Example 5
Source File: MainActivity.java    From kernel_adiutor with Apache License 2.0 6 votes vote down vote up
/**
 * Gets called when there is an input on the navigation drawer
 *
 * @param position position of the fragment
 */
private void selectItem(int position) {
    Fragment fragment = VISIBLE_ITEMS.get(position).getFragment();

    if (mScrimInsetsFrameLayout != null) mDrawerLayout.closeDrawer(mScrimInsetsFrameLayout);
    if (fragment == null || cur_position == position) return;
    cur_position = position;

    try {
        getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commitAllowingStateLoss();
    } catch (Exception e) {
        e.printStackTrace();
    }

    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setTitle(VISIBLE_ITEMS.get(position).getTitle());
    mAdapter.setItemChecked(position, true);
}
 
Example 6
Source File: ImageGalleryActivity.java    From ImageGallery with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            images = extras.getStringArrayList(KEY_IMAGES);
            title = extras.getString(KEY_TITLE);
        }
    }

    setContentView(R.layout.activity_image_gallery);

    bindViews();

    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(title);
    }

    setUpRecyclerView();
}
 
Example 7
Source File: BaseFragment.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (isRootFragment) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            if (titleRes != 0) {
                actionBar.setTitle(titleRes);
            } else {
                actionBar.setTitle(title);
            }
            actionBar.setSubtitle(subtitle);
            actionBar.setDisplayShowCustomEnabled(showCustom);
            actionBar.setDisplayHomeAsUpEnabled(homeAsUp);
            actionBar.setDisplayShowHomeEnabled(showHome);
            actionBar.setDisplayShowTitleEnabled(showTitle);
            onConfigureActionBar(actionBar);
        }
    }
}
 
Example 8
Source File: AboutActivity.java    From Kandroid with GNU General Public License v3.0 5 votes vote down vote up
private void  setupActionBar() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Show the Up button in the action bar.
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(getString(R.string.title_activity_about, BuildConfig.VERSION_NAME));
    }
}
 
Example 9
Source File: SettingsActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.text_settings);
    }
    if (!isDarkTheme()) {
        toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
    }
}
 
Example 10
Source File: BaseActivity.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
protected void setTitle(String title)
{
    ActionBar actionBar = getSupportActionBar();
    TextView toolbarTitle = findViewById(R.id.toolbar_title);
    if (toolbarTitle != null) {
        if (actionBar != null) {
            actionBar.setTitle(R.string.empty);
        }
        toolbarTitle.setText(title);
    }
}
 
Example 11
Source File: NavigationDrawerFragment.java    From Android-License-Fragment with Apache License 2.0 5 votes vote down vote up
/**
     * Per the navigation drawer design guidelines, updates the action bar to show the global app
     * 'context', rather than just what's in the current screen.
     */
    private void showGlobalContextActionBar() {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayShowTitleEnabled(true);
//        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setTitle(R.string.app_name);
    }
 
Example 12
Source File: FilePickerActivity.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPostExecute(FilePickerFragment fragment, List<RecyclerViewItem> items) {
    super.onPostExecute(fragment, items);

    BaseActivity activity = (BaseActivity) fragment.getActivity();
    ActionBar actionBar;
    if (activity != null
            && (actionBar = activity.getSupportActionBar()) != null) {
        actionBar.setTitle(fragment.mPath);
    }
}
 
Example 13
Source File: NavigationDrawerFragment.java    From android-sensor-example with Apache License 2.0 5 votes vote down vote up
/**
 * Per the navigation drawer design guidelines, updates the action bar to show the global app
 * 'context', rather than just what's in the current screen.
 */
private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setTitle(R.string.app_name);
}
 
Example 14
Source File: TodayFragment.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configToolbar() {
    if (getActivity() != null) {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setTitle(R.string.drawer_menu_today);
            actionBar.setSubtitle(null);
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white);
        }
    }
}
 
Example 15
Source File: SettingsSecurity.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
private void configToolbar() {
    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (actionBar != null) actionBar.setTitle(R.string.setting_data_security);
}
 
Example 16
Source File: TransactionDetailActivity.java    From alpha-wallet-android with MIT License 4 votes vote down vote up
private void setTitle() {
    findViewById(R.id.toolbar_title).setVisibility(View.VISIBLE);
    ((TextView)findViewById(R.id.toolbar_title)).setText(R.string.title_transaction_details);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle("");
}
 
Example 17
Source File: ToolbarActivity.java    From SeeWeather with Apache License 2.0 4 votes vote down vote up
protected void safeSetTitle(String title) {
    ActionBar appBarLayout = getSupportActionBar();
    if (appBarLayout != null) {
        appBarLayout.setTitle(title);
    }
}
 
Example 18
Source File: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    Defaults.setupInitialValues(getApplicationContext(), getIntent());

    if (!Defaults.ACTIVITY_THEME.isEmpty()) {
    		setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME));
    }

    setupIds();
    setContentView(main_layout_id);

    isMultipleSelection = (1 != Defaults.MAX_IMAGE_SELECTION);
    isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE;

    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        if (!Defaults.STATUS_BAR_COLOR.isEmpty()) {
        	window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR));
        }

        window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR));
    }

    ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
    		if (!Defaults.BAR_COLOR.isEmpty()) {
    			actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR));
        }

        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(Defaults.TITLE);

    } else {
    		Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG);
    }


    mRecyclerView = new RecyclerView(TiApplication.getInstance());
    mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mRecyclerView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, Defaults.GRID_SIZE));

    FrameLayout frame_container = (FrameLayout) findViewById(container);
    frame_container.addView(mRecyclerView);
    frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR));

    adapterSet = new PhotoAdapter(adapter);
    mRecyclerView.setAdapter(adapterSet);

    if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) {
    		mRecyclerView.addItemDecoration(new DividerDecoration());
    }

    setupGlideOptions(); // set glide-options to apply on image

    // Get gallery photos in a new UI thread like AsyncTask to update UI changes properly
    new FetchImages().execute();
}
 
Example 19
Source File: CrashActivity.java    From PlayMusicExporter with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_crash);

    // Reads the crash information
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        if (bundle.containsKey(EXTRA_FLAG_CRASH_MESSAGE))
            mCrashMessage = bundle.getString(EXTRA_FLAG_CRASH_MESSAGE);
        if (bundle.containsKey(EXTRA_FLAG_CRASH_LOG))
            mCrashLog = bundle.getString(EXTRA_FLAG_CRASH_LOG);
    } else {
        // No information; close activity
        finish();
        return;
    }

    try {
        // Get the PackageManager to load information about the app
        PackageManager packageManager = getPackageManager();
        // Loads the ApplicationInfo with meta data
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);

        if (applicationInfo.metaData != null) {
            // Reads the crash handler settings from meta data
            if (applicationInfo.metaData.containsKey("crashhandler.email"))
                mMetaDataEmail = applicationInfo.metaData.getString("crashhandler.email");
            if (applicationInfo.metaData.containsKey("crashhandler.supporturl"))
                mMetaDataSupportURL = applicationInfo.metaData.getString("crashhandler.supporturl");
        }

        // Gets the app name
        mAppName = packageManager.getApplicationLabel(applicationInfo).toString();
        // Gets the launch intent for the restart
        mLaunchIntent = packageManager.getLaunchIntentForPackage(getPackageName());

    } catch (PackageManager.NameNotFoundException ex) {
        // If this occurs then god must be already dead
        Logger.getInstance().logError("CrashHandler", ex.toString());
    }

    // Set the action bar title
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(getString(R.string.crashhandler_app_has_stopped_working, mAppName));
    }

    // Set the message
    TextView textViewMessage = (TextView) findViewById(R.id.text_view_crash_message);
    if (textViewMessage != null) {
        textViewMessage.setText(mCrashLog);
    }
}
 
Example 20
Source File: GroupMemberActivity.java    From talk-android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_member);

    ButterKnife.inject(this);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(R.string.group_manager);

    mGroup = Parcels.unwrap(getIntent().getParcelableExtra(GROUP));
    mAdapter = new GroupMemberAdapter(mGroup);

    final LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(manager);
    mRecyclerView.setAdapter(mAdapter);

    List<String> memberIds = Parcels.unwrap(getIntent().getParcelableExtra(MEMBER_IDS));
    MemberRealm.getInstance().getMembersByIds(memberIds)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<Member>>() {
                @Override
                public void call(List<Member> members) {
                    mAdapter.setMembers(members);
                }
            }, new RealmErrorAction());
    mAdapter.setOnRemoveListener(this);
    mAdapter.setOnItemClickListener(this);

    mSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.filter(newText);
            return false;
        }
    });
}