android-actionbar

Can I disable ActionBar's navigation Spinner?

China☆狼群 提交于 2019-12-21 19:17:08
问题 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

Dynamically add action item in action bar

戏子无情 提交于 2019-12-21 17:50:12
问题 I want to create my action menu items in the ActionBar totally dinamically for some reasons. But when I add the menu items from code, they are displayed as overflow of the setting menu item. Below there is my code. any solution? @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. //getMenuInflater().inflate(R.menu.start, menu); MenuItem logoutMI= menu.add(0,1,0,"Logout"); logoutMI.setShowAsAction(MenuItem.SHOW_AS

ActionBarActivity catch an error on Phone

我的梦境 提交于 2019-12-21 17:31:23
问题 ** I was recomended to use ActionBar Activity** Here is the previous code import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } I wrote new application and followed advice. import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app

set actionbar icon height to match actionbar height

大城市里の小女人 提交于 2019-12-21 13:11:46
问题 see the problem here, the grey checkbox leaves room from the top and bottom of the action bar: styles.xml <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="CustomActionBarTheme" parent="Theme.Base.AppCompat.Light"> <item name="android:windowContentOverlay">@null</item> <item name="android:actionButtonStyle">@style/ActionButtonStyle</item> </style> <!--<style name="ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton">--> <style name=

Remove actionbar item blue background

て烟熏妆下的殇ゞ 提交于 2019-12-21 12:36:22
问题 I am creating an actionbar with custom looking buttons that I put in the icon section of menu.xml. The problem is that, when I press them, I see both the selected version of the image of the button and the blue background of the holo theme. This is my menu.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/current_position" android:icon="@drawable/ab_location_layer" android:menuCategory="container" android:showAsAction="ifRoom" android:title=

getActionBar() returns null after SDK update to 5.0

为君一笑 提交于 2019-12-21 12:30:04
问题 After I updated the Android SDK to version 5.0 the getActionBar() method started to return null causing my app to crash on launch. I am clueless to what's causing this and any existing Stackoverflow threads didn't help. Here is my manifest: <application android:name="App" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/ActionBarTheme" > styles.xml: <style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style> <!--

ActionBar with AppCompat actionBarItemBackground not working

折月煮酒 提交于 2019-12-21 12:28:51
问题 I am trying to change the color of an item when it pressed. I used the actionBarItemBackground item in the action bar style, but nothing happens.. The color not changed... Here my code: <style name="ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar.Solid"> <item name="android:background">@color/actionbar_background</item> <item name="titleTextStyle">@style/ActionBarStyle.Title</item> <item name="actionBarItemBackground">@drawable/action_bar_item_selector</item> <item name="android

ActionBar with AppCompat actionBarItemBackground not working

我们两清 提交于 2019-12-21 12:26:34
问题 I am trying to change the color of an item when it pressed. I used the actionBarItemBackground item in the action bar style, but nothing happens.. The color not changed... Here my code: <style name="ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar.Solid"> <item name="android:background">@color/actionbar_background</item> <item name="titleTextStyle">@style/ActionBarStyle.Title</item> <item name="actionBarItemBackground">@drawable/action_bar_item_selector</item> <item name="android

getSupportActionBar() returns null with Robolectric

不问归期 提交于 2019-12-21 12:09:20
问题 The method getSupportActionBar() returns null when i invoke it through a Test Case based in Roboelectric and JUnit. This is my simple test case: package com.mobile.test; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import android.app.Activity; import android.content

Dynamic control of action/menu items in ActionBar

余生颓废 提交于 2019-12-21 12:04:22
问题 Is there a way to dynamically disable , hide, add/remove menu items in ActionBar ? For example, an action is disabled until user fills a valid phone number in an activity. I didn't find any useful methods in ActionBar API, the only way seems to be using a custom View in ActionBar. 回答1: To tell ActionBar to refresh its menu items: invalidateOptionsMenu() then to enable/disable Menu Items: @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item= menu.findItem(R.id.men_1); /