android-actionbar

java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.support.v7.widget.Toolbar$SavedState

廉价感情. 提交于 2019-12-17 16:30:45
问题 My app gets crashed frequently when it goes from background to foreground. Scenerio: Suppose iam playing any games and my app is in recent list and after playing,if i selects app,it will crash and shows the error. There is no toolbar in my app,Only actionbar i used. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fcords.android/com.fcords.android.Home.HomeScreen.HomePage_New}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.support

MenuItem's checked state is not shown correctly by its icon

℡╲_俬逩灬. 提交于 2019-12-17 15:56:15
问题 I have MenuItem defined this way: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_starred" android:icon="@drawable/btn_star" android:title="@string/description_star" android:checkable="true" android:checked="true" android:orderInCategory="1" android:showAsAction="always" /> </menu> and btn_star.xml defined this way: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state

Change Icon Of Navigation Drawer

非 Y 不嫁゛ 提交于 2019-12-17 15:29:58
问题 I am having trouble with changing my navigation drawer icon to a custom one. I've currently had to implement the standard drawer icon which has 3 horizontal lines on top, but now I want to replace this with my custom drawer icon. This is how my mDrawerToggle is at the moment: mDrawerToggle=new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.app_icon, R.string.drawer_open) { // My code }; 回答1: Here is the sample code taken from Creating a Navigation Drawer Activity.class public class

How to force overflow menu on android actionbar compat?

末鹿安然 提交于 2019-12-17 15:27:57
问题 Android action bar compat Is it possible? On older devices (pre 3.0) the items that don't fit the action bar are only shown when the menu key is pressed, I want these items to be grouped in the actionbar's overflow menu. 回答1: The action overflow menu is only available when there is no hard menu button available on the device. I found this stated in the Framework Topics under User Interface > Action Bar, check out the 3rd bullet here. There is an action bar library written by Jake Wharton

Styling ActionMode ActionBar in Android 5.0 Lollipop (with AppCompat)

情到浓时终转凉″ 提交于 2019-12-17 15:16:43
问题 I used this tutorial to facelift my Holo app for Lollipop: http://android-developers.blogspot.ru/2014/10/appcompat-v21-material-design-for-pre.html What I have: Theme <style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="windowActionModeOverlay">true</item> <item name="colorPrimary">@color/theme_primary</item> <item name="colorPrimaryDark">@color/theme_primary_dark</item> <item name="colorAccent">@color/theme_accent</item> </style> Toolbar layout <android.support.v7

Why my Android ActionBar doesn't update when it is explictily changed

醉酒当歌 提交于 2019-12-17 14:29:08
问题 I've seen questions on SO that related to these many times. So I've decided to post the reason why it happens and also the solution so that many SO users will get the benefit of the answer. For sometime now I've seen a reoccurring issue where I would change the ActionBar title and it would get ellipsized shorter than it should. Another symptom of this is having your title wrap when it shouldn't or just stay completely blank. When you change the the action bar buttons it wouldn't update

Action Bar not showing action view icons

淺唱寂寞╮ 提交于 2019-12-17 10:57:28
问题 I'm using the new Action Bar Support and all my action views are shown in overflow and not as icons in the bar. My app is for 7+ API. HomeActivity: public class HomeActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(R.string.app_name); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) {

How can I detect a click on the ActionBar title?

陌路散爱 提交于 2019-12-17 10:56:25
问题 For specific customer requirement, I need to allow the user of my app ( won't be published in Market) to click on the ActionBar title to execute some actions. I have been looking in the Android source, but I am not able to find an ID for the actionBar TextView title. Is there a proper way to handle such clicks? 回答1: The title is non-clickable AFAIK. The icon/logo is clickable -- you'll get that via android.R.id.home in onOptionsItemSelected() . Conceivably, the title also routes this way,

How to add dividers between specific menu items?

放肆的年华 提交于 2019-12-17 10:45:04
问题 Background I have a menu item in the action bar (toolbar actually) that when clicked, shows a list of items to choose from, similar to radio-buttons: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:icon="@drawable/..." android:title="@string/..." app:showAsAction="always"> <menu> <group android:id="@+id/..." android:checkableBehavior="single"> <item .../> <item .../> <item .../> </group> </menu> </item> </menu

OnCreateView called multiple times / Working with ActionBar and Fragments

时光总嘲笑我的痴心妄想 提交于 2019-12-17 10:19:45
问题 I switched part of my App from Activities to Fragments so that I can use the neat ActionBar tabs. However, after completing the transition I ran into an issue: whenever I switch to another tab, that Fragment gets created all over again. Both onCreate and onCreateView get called every time I get to a tab. I have 4 tabs, each of which is meant to open one of these fragments: Fragment ShopFragment = new WebActivity(); Fragment SearchFragment = new SearchActivity(context); Fragment StoreFragment