android-actionbar

getActionBar() returns null after SDK update to 5.0

吃可爱长大的小学妹 提交于 2019-12-04 05:43:41
After I updated the Android SDK to version 5.0 the getActionBar() method started to return null causing my app to crash on launch. I am clueless to what's causing this and any existing Stackoverflow threads didn't help. Here is my manifest: <application android:name="App" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/ActionBarTheme" > styles.xml: <style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"></style> <style name="ListItemPadding"

android webview: prevent text selection actionMode actionBar

╄→гoц情女王★ 提交于 2019-12-04 05:37:58
I want to preserve the text selection in a webView while preventing any contextual menu of the actioMode from being shown. Neither the new floating one nor the old actionBar, just the selection handles and of course the selection behaviour. Hooking to the actionModeCallback in startActionMode allows me to clear all items in the menu in the callback onCreateActionMode. This works fine on android 6, since an empty floating menu won't show at all, and the actionMode text selection behaviour is preserved. Unfortunately on android < 6 this leaves an empty actionBar shown, how can I completely

Remove actionbar item blue background

感情迁移 提交于 2019-12-04 05:27:53
I am creating an actionbar with custom looking buttons that I put in the icon section of menu.xml. The problem is that, when I press them, I see both the selected version of the image of the button and the blue background of the holo theme. This is my menu.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/current_position" android:icon="@drawable/ab_location_layer" android:menuCategory="container" android:showAsAction="ifRoom" android:title="Current position"> </item> </menu> The ab_location_layer is this: <selector xmlns:android="http://schemas

How to show a custom actionbar view from one fragment only

吃可爱长大的小学妹 提交于 2019-12-04 05:23:07
问题 I have a requirement for my app that a custom action bar view be shown from one fragment only (the landing page fragment). The problem is that this action bar is appearing when the user navigates to other fragments. Is there a way to do this without disabling custom view on every fragment? Thanks 回答1: For this issue, only show actionbar for one fragment without show on all other fragments, solution could be very easy: In your activity that hosts your fragments: @Override protected void

Android FragmentActivity returns null in getActionBar()

*爱你&永不变心* 提交于 2019-12-04 05:19:20
I have imported an Android sample project called HorizontalPaging in Android Studio and it works fine when I run it. But when I copied the code into my code, I get a NULL pointer exception in getActionBar() . I have been reading about these problems the whole day but can't get it working. Tried copying the entire code from the sample's MainActivity into my project but no improvements so I am guessing that the problem is in some other file like manifest,styles,etc. MainActivity.java copied from the sample project import android.app.ActionBar; import android.app.FragmentTransaction; import

getSupportActionBar() returns null with Robolectric

こ雲淡風輕ζ 提交于 2019-12-04 05:06:18
The method getSupportActionBar() returns null when i invoke it through a Test Case based in Roboelectric and JUnit. This is my simple test case: package com.mobile.test; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import android.app.Activity; import android.content.Intent; import com.mobile.android.core.R; import com.mobile.android.core.activity.MainActivity; import

dynamically enable/disable hide/unhide Android ActionBar action icon

点点圈 提交于 2019-12-04 04:55:25
I am developing an Android application that employs a standard ActionBar. on a certain screen i have a Filter icon that is conditionally required, depending on characteristics of the data being displayed, e.g. some data is filterable Others not. i cannot find any methods on actionbar that look likely candidates for programmaticaly hiding an actionbar action icon. how can i enable/disable an actionbar action icon? Or how can i hide/unhide an actionbar action icon? Have a look at this, it shows how to change menu items at runtime. http://developer.android.com/guide/topics/ui/menus.html

Swipe view with different actionbar items in each swipe fragment

六月ゝ 毕业季﹏ 提交于 2019-12-04 04:42:50
问题 I want to change the actionbar items on each swipe fragment. Actually I want submit button on actionbar for only third swipe fragment. For example I have 3 fragment in swipe "all,urgent,new" and I only want submit button on "new" fragment. I tried some code. here is it: public boolean onCreateOptionsMenu(Menu menu) { // add your refresh button to res/menu/main.xml getMenuInflater().inflate(R.menu.main, menu); mRefreshMenuItem = menu.findItem(R.id.action_submit); return true; } And on Page

How can I dismiss the Navigation Drawer to use the Back-home-icon button?

丶灬走出姿态 提交于 2019-12-04 04:39:40
I'm using the action bar with search bar too, and I need to use the ActionBar ico like a Back button: But I'm using the navigation drawer too... How can I dismiss/hide/disable the Navigation Drawer menu to use the back button? My ActionBar code: @Override public boolean onCreateOptionsMenu(Menu menu){ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); this.getSupportActionBar().setDisplayShowCustomEnabled(true); this.getSupportActionBar().setDisplayShowTitleEnabled(false); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); this.getSupportActionBar()

Hide only the Action bar on Scroll not action bar tabs

情到浓时终转凉″ 提交于 2019-12-04 04:30:59
I am getting an issue at trying to hide the action bar while scrolling down.Then while scrolling up,the action bar have to shown again. For Eg: I referred this Tutorial .Here you can see the output and respective codes related to hide and show the action bar. I am showing the output what I get it till now. After scrolling down: The screenshot above shown, it hide the action bar tab also.But it have to hide only the action bar.That's the major issue. After scrolling up: The screenshot above shows it displays back the action bar with tabs. TopRatedFragment.java: import info.androidhive.tabsswipe