android-actionbar

Up navigation and saved instance data

a 夏天 提交于 2020-01-01 08:59:07
问题 An app has 2 activities, A and B. A has instance data that is saved @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("foo", 0); } and A has int bar; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ... if (savedInstanceState != null) { bar = savedInstanceState.getInt("foo"); } else { bar = -1; } } to restore the data. Activity B has the actionbar enabled and @Override public void onCreate

Android ActionBar backbutton and tabs

可紊 提交于 2020-01-01 08:57:15
问题 I want to create an ActionBar and a tabbed navigation like the google+ app. I used this example as a starting point and now I have a great actionbar: http://developer.android.com/resources/samples/ActionBarCompat/index.html I've also included a ViewPager and a TabHost to have tabs and scrolling left/right Fragments. What i need is to show the back arrow in version prior to honeycomb. If I set getActionBar().setDisplayHomeAsUpEnabled(true) , the arrow is automatically show in version >=

how to set NAVIGATION_MODE_LIST on Toolbar new appcompat v7 21

风格不统一 提交于 2020-01-01 08:34:10
问题 Now all methods related to navigation modes in the ActionBar class, such as setNavigationMode() ... are now deprecated. The documentation explains: Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead. In my current application, there is a spinner on ActionBar. How do I apply NAVIGATION_MODE_LIST on the new widget Toolbar in the new version appcompat v7 21. Thanks in advance. 回答1: With the API 21

Detect if a ScrollView is scrolling up or down - Android

自闭症网瘾萝莉.ら 提交于 2020-01-01 06:48:25
问题 I have one ScrollView with one LinearLayout with TextView s. I want to detect when ScrollView is scrolling up or down to hide/show ActionBar . 回答1: you need to create a class that extends ScrollView public class ExampleScrollView extends ScrollView and then Override onScrollChanged that gives you the old and new scroll positions and from there you can detect which direction protected void onScrollChanged(int l, int t, int oldl, int oldt) 回答2: check this out scrollView.setOnTouchListener(new

AppCompat - Item not showing in action bar for API levels v8-13

我的梦境 提交于 2020-01-01 05:05:07
问题 I have one item I want to always display in the action bar using the AppCompat library. It's just a sub menu using the default overflow image. This is not working for me on API levels v8-13 and I've done everything the developer guide says, including adding my own namespace. I'm using a custom style which has Theme.AppCompat as its parent (below). This is my first post so I don't have enough reputation points to post an image of the activity, but the item is missing from the action bar and

adding buttons to android action bar

喜欢而已 提交于 2020-01-01 03:18:05
问题 How can i make the buttons with text,with images in action bar like below. Is it possible to use Inbuilt android button or image button to do like below in action bar. I am using appcompat to use action bar. 回答1: Yes, you can inflate a custom actionbar if you need. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater = (LayoutInflater) getActionBar() .getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE); View

Change appcompat's SearchView text and hint color

坚强是说给别人听的谎言 提交于 2020-01-01 01:18:09
问题 Does anybody know how to change the text color of the appcompat SearchView? I've spent 2 hours and tried several suggestions from SO and none works. Here is my code: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:espacios="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/layer_switcher_button" android:icon="@drawable/b_categorias" android:title="@string/menu_layer_switcher_title" espacios:showAsAction="ifRoom|collapseActionView"/> <item android:id="@

Android statusbar overlay with ActionBar

风格不统一 提交于 2020-01-01 01:17:11
问题 I know that I can make the ActionBar overlay using requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY) and can toggle/show the status bar in my screen (by switching between FLAG_FULLSCREEN and FLAG_FORCE_NOT_FULLSCREEN ). This works great. However, I don't want my layout moving when I toggle the status bar. I know that I can make the status bar "overlay" (albeit not transparently) the content using: WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN WindowManager.LayoutParams.FLAG_LAYOUT_NO

Implementing ActionBar tabs with v4 Fragments API

六月ゝ 毕业季﹏ 提交于 2020-01-01 01:13:14
问题 My app is currently using the Fragments/v4 compatibility package to support Android versions all the way down to 1.6. This means all my Fragments inherit from the compatibility package's version of Fragment . I'm currently trying to rework parts of the app to take advantage of Honeycomb features, like ActionBar . I already use my own action-bar-like implementation on pre-3.0 devices, and the Honeycomb Action Bar otherwise. This bit isn't an issue. The problem I have is trying to implement

Android: Calling non-static methods from a static Handler class

不羁岁月 提交于 2019-12-31 22:27:30
问题 Given this code: public class MainActivity extends FragmentActivity implements ActionBar.TabListener { public static final int MESSAGE_NOT_CONNECTED = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); } // ------------------------------------------------- public final void setStatus(int Rid) { final ActionBar actionBar = getActionBar(); actionBar.setSubtitle(Rid); } // --------------------------------------