android-actionbar

How to change the position of menu items on actionbar

二次信任 提交于 2019-12-20 19:35:15
问题 I'm developing one application in which I have to add a custom layout on actionbar. Adding the custom layout is done, but when I'm adding the menu items on actionbar my custom layout changes it's position from right of the actionbar to center of the actionbar. Below is the image what I have achieved so far. I want something like this on the actionbar. Custom layout(yellow button) at the right most part of actionbar and menu items in the middle. Adding my code to achieve this custom layout

AppCompat Actionbar styling

强颜欢笑 提交于 2019-12-20 18:31:19
问题 I'm currently trying to use AppCompat instead of ActionbarSherlock. On Android 4+ devices I don't run into any problems, as the normal Actionbar and Holo theme are used. On lower Android versions however, this weird look happens when using Theme.AppCompat.Light. The Actionbar is white and has a blue line underneath. I was able to fix that by using the Android Action Bar Style Generator from Android Asset Studio to generate a custom theme with a solid Actionbar instead of the transparent one.

Trying to hide and show menu items on action bar

旧街凉风 提交于 2019-12-20 12:15:15
问题 I have looked through the questions on stack overflow and can't find the solution. @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.themenu, menu); MenuItem item = menu.findItem(R.id.menu_settings); MenuItem item2 = menu.findItem(R.id.menu_save); item.setVisible(isdown); item2.setVisible(isdown); return true; } This sets my menu items to visible (item1 and item2). the onclick works fine public void inflateTextarea()

ActionBar Tabs - Fixed and Scrollable?

拟墨画扇 提交于 2019-12-20 11:59:24
问题 In the Android Design Guidelines it states that "There are two types of tabs: fixed and scrollable." I can't find any documentation in the ActionBar documentation to support the ability to specify either type of tabs. How do you specify a tab group to be fixed or scrollable? If you can't, what governs whether the tabs are fixed or scrollable exactly? 回答1: The number of tabs dictates whether the tab group is fixed or scrollable. For example, if you have one tab, they'll be fixed but if you

ActionBar capacity/overflow not changing on orientation change

丶灬走出姿态 提交于 2019-12-20 10:44:24
问题 I have an app using the ActionBar, where I handle orientation changes myself: android:configChanges="keyboard|keyboardHidden|orientation|screenSize" ...and the menu should fit in the ActionBar without overflow in landscape, but not in portrait: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:title="@string/Game" android:id="@+id/game" android:icon="@android:drawable/ic_menu_manage" android:showAsAction="ifRoom|withText"/>

Change ActionBar title using Fragments

社会主义新天地 提交于 2019-12-20 10:30:21
问题 I'm using Actionbar. I have a Fragment call Favorites where i save some contacts as favorites. When you click on one contact it takes me to another fragment an put the contact number on a editText. The new fragment is call Transfers. So my problem is that when the user clicks the contact, that takes me to the other fragment but the title on the action bar still with the favorite title and not the new one, how to change that title? I have already try to use setTitle on the click method but

Custom Home Icon in Action Bar Sherlock

南楼画角 提交于 2019-12-20 10:22:53
问题 I am trying to set custom icon for home icon using ActionBarSherlock library. I have tried to set custom layout using abHomeLayout attribute in my custom theme. But it didn't work for me. Only way, how to set it, is to set abIcon attribute for my custom drawble, but I cannot set some horizontal padding for this drawable. Is there any example for this or where could be a problem with abHomeLayout attribute? 回答1: This works for my situation, it replaces the default ic_launcher icon in the

What is the alternative to getActionView() before API level11 in android?

依然范特西╮ 提交于 2019-12-20 10:18:25
问题 getActionView() for action bar was introduced in API 11 , If I want backward compatibility what is the alternative for getActionView() ? e.g. public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.action_bar_menu, menu); final MenuItem item = menu.findItem(R.id.menuitem); item.getActionView() //Works from API level 11 return true; } 回答1: For backwards compatibility you can use either ActionBarCompat or ActionBarScherlock . In both cases you can use the method

getSupportActionBar().setTitle() vs toolbar.setTitle()

微笑、不失礼 提交于 2019-12-20 10:11:37
问题 I am aware that there are two methods to setting a title in an Android Activity . Assuming I already have the following code... @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_activity); ... Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar); setSupportActionBar(toolbar); ...I can use either this... getSupportActionBar().setTitle("My title"); ...or this... toolbar.setTitle("My title"); ...to set my title. My

Transaction between fragments only inside one ActionBar Tab

半城伤御伤魂 提交于 2019-12-20 09:53:19
问题 I have an app with three tabs (ActionBar Tabs), each one with one fragment at a time. TabListener TabsActivity Tab1 -> ListFragment1 -> ListFragment2 -> Fragment3 Tab2 -> Tab2Fragment Tab3 -> Tab3Fragment The problem is when I create the FragmentTransaction (inside OnListItemClicked) from ListFragment1 to ListFragment2, the fragments inside the other tabs also change to ListFragment2. In the end, I want to change fragments only inside on tab and preserve the state of the other tabs. I'm