android-actionbar

Different titles for each fragment in my viewpager

冷暖自知 提交于 2020-01-12 04:31:26
问题 I am using a viewpager "tabs + swipe" and I would like to set different titles in the actionBar for each fragment so that when I switch, title changes. I tried several things without success, only the last title displays... and does not change anymore when I switch... 回答1: First, make your activity implement an OnPageChangeListener. Then, when you create your ViewPager , you can use mViewPager.setOnPageChangeListener(this) so that your activity will receive callbacks when the page changes.

Actionbar button background

こ雲淡風輕ζ 提交于 2020-01-12 03:33:06
问题 I want to customize actionbar buttons with an image both for pressed and not pressed state. I put a drawable selector on android:icon with two states (pressed and not pressed). The problem is that, if I press the button, I still have the blue background (ics holo style) along with my pressed button icon. How can I remove this behaviour from actionbar customized icon buttons? Thanks 回答1: I think the more specific way is to put this attribute in your application Theme: <item name="android

Home button in action bar not working in Lollipop

妖精的绣舞 提交于 2020-01-11 19:54:11
问题 I have a problem, cause I'm developing app for lollipop without support library v7 , so I need to use standard ActionBar . Previously I used setHomeButtonEnabled in multiple activities with actionBar . When I switched app theme to material everything is working fine, except setHomeButtonEnabled method. Title is not clickable. Help! 回答1: For some reason, someone at Google decided that these should become no-op's. This can be seen below. ToolbarWidgetWrapper.java @Override public void

Change the title text color in the Android ActionBar via xml

♀尐吖头ヾ 提交于 2020-01-11 11:37:40
问题 I want to change the title text color of the ActionBar in my app. I have tried in many ways but I can't achieve it. I don't want to do it programatically because when the app is launched it shows the action bar with previous color and then changes to the new one. I'm supporting from Api Level 8 and my xml was generated with the Android Action Bar Style Generator. Then I tried to change the title text color with this . The title text color is still black. This is my code: <resources> <style

Change the title text color in the Android ActionBar via xml

拥有回忆 提交于 2020-01-11 11:37:06
问题 I want to change the title text color of the ActionBar in my app. I have tried in many ways but I can't achieve it. I don't want to do it programatically because when the app is launched it shows the action bar with previous color and then changes to the new one. I'm supporting from Api Level 8 and my xml was generated with the Android Action Bar Style Generator. Then I tried to change the title text color with this . The title text color is still black. This is my code: <resources> <style

custom style action bar not working in android 4

为君一笑 提交于 2020-01-11 09:22:17
问题 For customizing my action bar I use code below in xml: <style name="CustomActionbarTheme" parent="@style/Theme.AppCompat.Light"> <item name="actionBarTabStyle">@style/customTab</item> <item name="actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar"> <item name="background">@drawable/title_bar</item> </style> <style name="customTab" parent="@style/Widget.AppCompat.ActionBar.TabView"> <item name="android:background">@drawable

custom style action bar not working in android 4

◇◆丶佛笑我妖孽 提交于 2020-01-11 09:21:47
问题 For customizing my action bar I use code below in xml: <style name="CustomActionbarTheme" parent="@style/Theme.AppCompat.Light"> <item name="actionBarTabStyle">@style/customTab</item> <item name="actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar"> <item name="background">@drawable/title_bar</item> </style> <style name="customTab" parent="@style/Widget.AppCompat.ActionBar.TabView"> <item name="android:background">@drawable

Remove action bar shadow programmatically

空扰寡人 提交于 2020-01-10 17:43:31
问题 How can i remove the drop shadow of action bar from java code ?. If i remove from the style it is working fine. <style name="MyTheme" parent="Theme.Sherlock"> .... <item name="windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item> .... </style> But i need to remove and add it dynamically from java code. 回答1: There is no way to set value for windowContentOverlay attribute programmatically. But you can define two different themes, one for Activities with a

FragmentPagerAdapter troubles and woes: Constructor Undefined

妖精的绣舞 提交于 2020-01-10 17:42:08
问题 Edit: I have reworked some of my code to try and get past the error (but now the app crashes on launch). First, my class now extends FragmentActivity so that I can access the method, getSupportFragmentManager();. Then, within on create, I changed my constructor: mTabsAdapter = new TabsAdapter(this.getSupportFragmentManager(), this, mViewPager); From there, in my subclass, I changed the code to reflect this: public TabsAdapter(FragmentManager fm, Activity activity, ViewPager pager) { super(fm)

How to create button in Action bar in android

穿精又带淫゛_ 提交于 2020-01-10 08:49:08
问题 I am working on android application where i need a button in action bar. These are my activity and java files. So, i need a button at right side of my tool bar. Thanks in advance. content_b2_bdeliveries.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"