android-actionbar

Android- hide actionbar during startup and then show it again?

泄露秘密 提交于 2019-12-22 03:50:56
问题 My android app has tab navigation using an action bar. It works well, but it bothers me that during the first boot of the app, a small default action bar briefly shows up before being replaced by the real, tab-navigation action bar. My onCreate starts like this: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_main); //Set up the actionbar final ActionBar actionBar

Height of screen without status bar, actionBar and tabs

大城市里の小女人 提交于 2019-12-22 01:53:56
问题 I have a ListView that I want each row to fill a third of the available screen. I have the status bar visible, and then an actionBar with slidingTabs beneath. I'm doing the current calculation like this: height = context.getResources().getDisplayMetrics().heightPixels; if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,context.getResources().getDisplayMetrics()); Log.d("actionBarHeigth",

Start ICS emulator without Menu button

梦想的初衷 提交于 2019-12-22 01:41:06
问题 I'm trying to see the overflow menu in the ActionBar on ICS and I don't have a device. I'm using the emulator and want to know, how do I start the emulator without a Menu button? I want to emulate a device with no Menu hardware button. I've looked on: http://developer.android.com/guide/developing/tools/emulator.html but I don't see how to do this. Thanks for any help. 回答1: Ok, so just the next day Reto Meier posted on G+ that the new tools (version 16) have an option in the emulator that

Android Update toolbar/actionbar title from Adapter

余生长醉 提交于 2019-12-22 01:31:21
问题 How can I update ActionBar title from Adapter? I tried this: ((MainActivity) getActivity()).getSupportActionBar().setTitle(getString(R.string.home_item)); but this way only works within fragments. So I do this: ((MainActivity) view.getContext()).getSupportActionBar().setTitle(getString(R.string.home_item)); and get cast exception. I don't know how to do it. So it is possible to update ActionBar Title from Adapter? Thanks 回答1: pass the activity context in your adapter. Myadapter adapter = new

Android custom back button with text

旧时模样 提交于 2019-12-22 01:07:46
问题 I want in my Android app an action bar like the one I have in my iOS app: . Unfortunately I don't know how to make the back button with text only and how to move the title in the center. This would be for the entire application, not only one layout. Could anyone help me, please? 回答1: I have found a simple solution. You have just to create a layout for a custom ActionBar custom_action_bar_layout.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android

ActionBar in API 8-10 in Android

大兔子大兔子 提交于 2019-12-22 00:24:10
问题 i want to use ActionBar in API level 8-10. i search solutions and find out 2 links bellow, but they are not useful for me.is there someone who has the same experience?Thanks! this is my code: ActionBar actionBar =getActionBar(); assert actionBar != null; actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#e32238"))); link1 link2 when i run the proje,these errors are shown: 回答1: ActionBar added in Android 3.0 (API level 11), but you can use it in ealier API 11 by using Spport

Center Action bar title

耗尽温柔 提交于 2019-12-22 00:18:11
问题 How can I center activity's action bar title in Android? I've seen MANY questions on SO for this specific topic. And every answer comes back to "using custom view" and having your own toolbar. I've found a solution that works without creating a custom view. 回答1: Have this method in your Activity : private void centerTitle() { ArrayList<View> textViews = new ArrayList<>(); getWindow().getDecorView().findViewsWithText(textViews, getTitle(), View.FIND_VIEWS_WITH_TEXT); if(textViews.size() > 0) {

onPrepareOptionsMenu Duplicates item in ActionBar

旧巷老猫 提交于 2019-12-21 21:27:55
问题 When I add a menu item using onPrepareOptionsMenu, the menu item duplicates its self in the action bar. I'm using fragments and creating the initial menu in the ActionBar in the main activity like this: ... @Override public boolean onCreateOptionsMenu(Menu paramMenu) { super.onCreateOptionsMenu(paramMenu); paramMenu.add(0, 1, 0, "DashBoard").setIcon(R.drawable.ic_dashboard) .setShowAsAction(1); return true; } I'm then adding another item in one of the fragments as follows: ... @Override

Applying custom theme to ActionBar in PreferenceFragment

家住魔仙堡 提交于 2019-12-21 19:53:45
问题 I am trying to apply custom theme to ActionBar in PreferenceFragment . Following is the scenerio: My class extends PreferenceFragment in which I am adding preferences from resouces as: addPreferenceFromResource (R.xml.myPrefs); Also, I have written: ActionBar a = getActivity ().getActionBar (); bar.setNavigationMode (ActionBar.NAVIGATION_MODE_TABS); Now I want to apply my own theme that I defined in styles.xml to this action bar. Currently, the height of action bar is smaller that the tab

Can I disable ActionBar's navigation Spinner?

和自甴很熟 提交于 2019-12-21 19:18:09
问题 What I want to achieve is disabling all items on ActionBar except one. I have a custom ActionBar with Menu ,several TextViews , one Button and a Spinner from ListNavigation. Spinner is created because of bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); like this : SpinnerAdapter spinnerAdapter = new ArrayAdapter<String>(this.getActivity(), R.layout.action_bar_spinner, names); // "listener" for spinner bar.setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() { @Override