android-switch

Unable to change switch color

孤者浪人 提交于 2019-12-12 15:45:11
问题 I'm looking for applying this color to all switches only. But by default, it is taking colorAccent instead of this theme for switch. Device: marshmallow. layout: <Switch android:id="@+id/soundSwitch" style="@style/SwitchStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginBottom="@dimen/large_space" android:layout_marginRight="@dimen/medium_space" android:layout

Android - clicking on a widget inside a clickable cardview

戏子无情 提交于 2019-12-11 04:12:42
问题 After fighting and eventually implementing this: RecyclerView onClick I manage to make the cardviews clickable and long-clickable. This is working well, or maybe too well, because I also want a certain widget inside the cardview to be clickable so when clicking on it, the cardview should ignore the click, what happens now is that both the widget and the cardview, consume the click. Here is the code: The recyclerview: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Android, Hide stock toggle when using custom background?

自闭症网瘾萝莉.ら 提交于 2019-12-08 04:02:15
问题 I've got a custom drawable for my toggle switch // toggle_selector.xlm <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/toggle_on" android:state_checked="true"/> <item android:drawable="@drawable/toggle_off" android:state_checked="false"/> </selector> Which I then apply to the switch <Switch android:id="@+id/geoLocationsToggle" android:background="@drawable/toggle_selector" android:layout_width="0dp"

SwitchPreference Listener with Custom Layout

核能气质少年 提交于 2019-12-07 22:43:10
问题 I'm trying to use a SwitchPreference in my Settings page, but i can't get the listener to work. I am using a custom widget layout in order to style the switch, as I cannot find how to use themes to achieve this. In my settings.xml i have the following: <SwitchPreference android:key="uitestmode" android:summary="Enable to display test data in fragments" android:title="UI Test Mode" android:widgetLayout="@layout/widget_custom_switch_on_off" > </SwitchPreference> and my SettingsFragment looks

How to flip the checked status of a Switch only after confirm dialog?

你离开我真会死。 提交于 2019-12-07 21:55:12
问题 My problem is - when I click on a <Switch>, it gets toggled first and then the OnCheckedChangeListener is called. What I would like is this: <Switch> is clicked --> I show an AlertDialog --> If pressed yes or no --> Then flip ` with setChecked(boolean), [boolean = true if pressed yes, and false if pressed no]. Problem : When <Switch> is clicked, it gets flipped automatically. I want to qualify it with a yes or no from a AlertDialog first. sw_enableDisable .setOnCheckedChangeListener(new

Switch button not showing up in ActionBar?

别等时光非礼了梦想. 提交于 2019-12-07 20:17:04
问题 I have a Switch that I placed into my ActionBar, but it doesn't seem to show up and I don't see why. This was my attempt: create_post_menu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".CreatePost"> <item android:id="@+id/toggle_test" android:title="" app:showAsAction="ifRoom" android:orderInCategory="1" android

Android, Hide stock toggle when using custom background?

守給你的承諾、 提交于 2019-12-06 15:58:28
I've got a custom drawable for my toggle switch // toggle_selector.xlm <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/toggle_on" android:state_checked="true"/> <item android:drawable="@drawable/toggle_off" android:state_checked="false"/> </selector> Which I then apply to the switch <Switch android:id="@+id/geoLocationsToggle" android:background="@drawable/toggle_selector" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:textOff="" android:textOn=""

How to flip the checked status of a Switch only after confirm dialog?

我的梦境 提交于 2019-12-06 14:24:40
My problem is - when I click on a <Switch> , it gets toggled first and then the OnCheckedChangeListener is called. What I would like is this: <Switch> is clicked --> I show an AlertDialog --> If pressed yes or no --> Then flip ` with setChecked(boolean) , [boolean = true if pressed yes, and false if pressed no]. Problem : When <Switch> is clicked, it gets flipped automatically. I want to qualify it with a yes or no from a AlertDialog first. sw_enableDisable .setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean

SwitchCompat not showing thumb image on Android 5.0 lollipop emulator

为君一笑 提交于 2019-12-06 08:27:24
问题 I read about the new SwitchCompat that has been introduced to implement the Switch widget in Android 5.0. I tried using the same but I am not able to see the drawable thumb image as seen in below image. My XML code is as follows, <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout

SwitchPreference Listener with Custom Layout

谁说胖子不能爱 提交于 2019-12-06 07:44:49
I'm trying to use a SwitchPreference in my Settings page, but i can't get the listener to work. I am using a custom widget layout in order to style the switch, as I cannot find how to use themes to achieve this. In my settings.xml i have the following: <SwitchPreference android:key="uitestmode" android:summary="Enable to display test data in fragments" android:title="UI Test Mode" android:widgetLayout="@layout/widget_custom_switch_on_off" > </SwitchPreference> and my SettingsFragment looks like: SwitchPreference uiTestModePref = (SwitchPreference) findPreference("uitestmode"); uiTestModePref