android-actionbar

Add Switch widget to ActionBar and respond to change event

早过忘川 提交于 2019-12-09 04:53:26
问题 Can I know how to add Switch widget in ActionBar and handle the click event or toggle change event. For now I can inflate the Switch in ActionBar but unable to respond to change event. I have added below to main.xml. <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.MainActivity" > <item android:id="@+id/toggleservice" android:actionViewClass="android.widget.Switch" android:showAsAction="ifRoom" android

Get Current Fragment and Save on onSaveInstanceState() Method For Screen Orientation

隐身守侯 提交于 2019-12-09 04:44:18
问题 I have one Activity with multiple Fragments. I am also using actionbarSherlock for my tabs which also connected to fragments. My Problem is when I am going to rotate the screen (that is portrait to landscape/vice-versa), my activity will be called again so it restarts my activity. I want not to restart my activity but just restore the current fragment that was shown before it was rotate. PLEASE don't answer android:configChanges="orientation|keyboardHidden" since it does not solved the issue

how to highlight a menu item on selection? [duplicate]

送分小仙女□ 提交于 2019-12-09 03:39:42
问题 This question already has an answer here : How to remove blue glow from Sherlock action bar menu item? (1 answer) Closed 6 years ago . How to highlight menu item on selection, I tried modifying styles.xml with various attributes like colorPressedHighlight , colorActivatedHighlight , etc. Is there any way to keep the menu item focussed until other item is selected? AndroidManifest.xml: <style name="onPressedHighLight" parent="AppBaseTheme"> <item name="android:colorActivatedHighlight">@color

android title won't show in toolbar

痞子三分冷 提交于 2019-12-09 02:07:22
问题 I have an xml that I use with so many activities with fragments file but my problem is that I can't display the text I want in the toolbar, I use that xml that way because I have a navigation drawer and I needed to handle somethings so I had to do it that way. my xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/frame_container" android:layout_width="match_parent" android:layout_height="match_parent"

Double fragment rotating Android with ActionBar

徘徊边缘 提交于 2019-12-08 22:49:16
问题 I've made a simple Android Activity with an ActionBar to switch between 2 fragments. It's all ok until I rotate the device. In facts, when I rotate I've got 2 fragment one over the other: the previous active one and the first one. Why? If the rotation destroy and recreate my activity, why I obtain 2 fragments? Sample code: Activity package rb.rfrag.namespace; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.Activity; import android.os.Bundle; public class

Double callbacks onMenuOpened/onPanelClosed on each menu button press

烈酒焚心 提交于 2019-12-08 19:30:03
问题 In my Android app I want to collect statistics on when (how often) the overflow (three dots) action bar menu is opened and closed (without an item being selected). For this task I have overriden onMenuOpened and onPanelClosed methods within an Activity . However, on all the devices (Android 4.4, 4.2; Samsung and HTC) I've tried this so far these methods are triggered twice, each time the menu is opened and closed. Is this a bug? Is there another way to monitor this menu opening and closing?

Could not lock surface

本秂侑毒 提交于 2019-12-08 18:44:54
问题 I added an ActionBar to my app and now I am consistently running into this issue. I am testing on a Galaxy S4 . This issue causing the app to slow down and become unresponsive. here is my code: //Get action bar actionBar = getActionBar(); //hide title to make room for spinner dropdown actionBar.setDisplayShowTitleEnabled(false); //set the mode actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); //spinner = (Spinner)findViewById(R.id.spinner); quotetext = (TextView)findViewById(R.id

ProgressBar in ActionBar on Android L Preview

旧时模样 提交于 2019-12-08 16:58:42
问题 Today I started porting an app to Android L preview in order to have it almost ready when the final product launches. One problem I found is that I can't have an indeterminate progressbar on the ActionBar. It doesn't show at all and throws this error on logcat: E/PhoneWindow﹕ Circular progress bar not located in current window decor I'm using this code, which works in <4.4: requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(true); Is there any

Change android EditText style from rectangular border to underscore

十年热恋 提交于 2019-12-08 16:41:06
问题 In one of my activities, my EditText views used to look like this But now they looks like this I need help changing it back: from the rectangle to the underscore. BACKGROUND Because I needed to create a custom ActionBar, I had to change the theme of the activity in question, YesterdayActivity , using the following Style: <style name="CustomWindowTitleBackground"> <item name="android:background">#323331</item> </style> <style name="CustomTheme" parent="android:Theme"> <item name="android

Placing/Overlapping (z-index) a view above actionbar tabs

牧云@^-^@ 提交于 2019-12-08 15:59:23
问题 I have a View that draws something outside the Fragment containing it and I configured it to draw the content outside it using this. The problem is that it works everywhere but on the ActionBar and ActionBar Tabs. mActionBar.addTab( mActionBar.newTab() .setCustomView(t)); I am using appCompat and adding tabs this way: I added android:clipChildren="false" to all the parent Views, but it doesn't work just for ActionBar and ActionBar tabs. The desired view: But the result is this: 回答1: It's not