android-actionbar

Actionbar centered title with buttons

本秂侑毒 提交于 2019-12-05 17:49:57
I would like to center the title in the action bar, while having action icons next to it(and ignoring them for the gravity setting). I would like to have this: Instead I have this: Here is my code: ActionBar actionBar = getSupportActionBar(); ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.top_bar)); actionBar.setCustomView(LayoutInflater.from(this).inflate(R.layout.actionbar_layout, null), params); actionBar.setDisplayShowCustomEnabled

Android remove app icon action bar

百般思念 提交于 2019-12-05 17:33:53
问题 Hello everyone i create ActionBar. viewpages and custom action bar.Now i want to remove(hide) app icon in ActionBar i used setDisplayShowHomeEnabled(false); but nothing happened. This is a my code public class MainActivity extends FragmentActivity implements TabListener { private ViewPager viewPager; private TabsPagerAdapter mAdapter; private ActionBar actionBar; private String[] tabs = { "test1", "test1", "test1", "test1", "test1" }; @Override public void onCreate(Bundle savedInstanceState)

changing title text color and size of menu android action bar

岁酱吖の 提交于 2019-12-05 16:56:43
I am developing android application and in my application I am using Sherlock action bar. I am using some menu into my action bar. <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/card_menu" android:title="C123" android:showAsAction="always"> <menu> <item android:id="@+id/C0" android:title="C0"/> <item android:id="@+id/c1" android:title="c1" /> <item android:id="@+id/c2" android:title="c2" /> </menu> </item> <item android:id="@+id/notification" android:title="Notifications" android:showAsAction="always" android:actionLayout="@layout/notification_icon"

Can't find Android Compatibility Package on SDK Manager

雨燕双飞 提交于 2019-12-05 16:38:40
I want to start learning to work with Fragments and I want to install the Compatibility package for pre 3.0 versions of Android. However, I can't seem to find this package on the SDK manager. Here's everything I see: Also, I want to install Action Bar Sherlock to work with Action Bars. On the ACS website it says "If you’re using the Eclipse Development Environment with the ADT plugin version 0.9.7 or greater you can include this as a library project" - how do I include library projects? Thanks It's called the Android Support Package . Referencing Library Projects Assuming you're using Eclipse,

Setting action bar title in ViewPager

你说的曾经没有我的故事 提交于 2019-12-05 16:05:49
My ViewPager consists of many fragments .I am displaying title of fragment inside actionBar and i am using below code to set title .Since the ViewPager also initiates adjacent fragments I see in actionbar the title of next fragment.What should be the correct way to proceed in setting the title in actionbar of viewpager? private class MyPagerAdapter extends FragmentPagerAdapter { private String[] titles = { "Titleme", "Titletos", "Titleos", "Titles", "MeTitle5", "Title6", "Title7", "Title8" }; public MyPagerAdapter(FragmentManager fm) { super(fm); } @Override public CharSequence getPageTitle

Selecting Native Tabs while Espresso testing

China☆狼群 提交于 2019-12-05 15:48:21
I have a viewpager which utilizes the native actionbar Tabs as the indicator. I would like to navigate to different tabs, but Tab component is not a view therefore, onView, or withText does not work properly with perform clicks. Is there a specific way I can do to navigate through the Tab navigation? Eduard Kotysh You could use swiping to navigate between your tabs: onView(withId(R.id.viewpager)).perform(swipeLeft()); onView(withId(R.id.viewpager)).perform(swipeRight()); Assuming there is text on the tab, you can do: onView(withText("Tab Text")).perform(click()) onView, withText and click are

How do I programmatically change ActionBar menuitem text colour?

醉酒当歌 提交于 2019-12-05 15:24:04
问题 I have an actionBar with multiple items, I would like to change the colour of the text when the item is clicked. Is there anyway to do this programmatically? Please provide and example or any resources. Thanks public void catalogClick(MenuItem item){ //highlight menuitem etc. } 回答1: Follow this link which explains how to change menuitem text programmatically. http://developer.android.com/guide/topics/ui/actionbar.html#Style Check for android:actionMenuTextColor for defining a style resource

Android opening specific tab fragment on notification click

[亡魂溺海] 提交于 2019-12-05 14:55:33
I have an android application which uses Action Bar Tabs. There is also a notification system. I want to open a specific tab directly, on clicking the notification. How to do this(because notification pending intents can only open activities, and my main activity contains 3 fragments for 3 tabs) ? Following is the code for the mainactivity for tabs. public class MaintabActivity extends Activity { public static Context appContext; public static MapView mMapView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

How do I get action buttons with custom layouts to be styled like standard action buttons in Android 3.0+

纵然是瞬间 提交于 2019-12-05 14:49:34
I'm having a bit of trouble with custom action buttons in the honeycomb+ action bar. I'm adding a menu item that uses a custom layout (using the android:actionLayout attribute). The reason for the custom layout is that I want a button that has two lines of text that can be updated dynamically. However, I still want this action button to operate like the other standard buttons. By this I mean that the background fades in when the button is selected, and fades out again if it is unselected, all in the style of the platform (the colour seems to differ between different platforms/devices - I've

Get Toolbar's navigation icon view reference

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 13:47:11
问题 I would like to highlight drawer icon in my Toolbar (working on a tutorial). For that, I need its position. How do I get a reference to drawer's navigation icon (hamburger) view? 回答1: You can make use of content description of the view and then use findViewWithText() method to get view reference public static View getToolbarNavigationIcon(Toolbar toolbar){ //check if contentDescription previously was set boolean hadContentDescription = !TextUtils.isEmpty(toolbar