Questions tagged [android-switch]

Switch is an android class for a two state toggle switch

From Android Developer Documentation:

A Switch is a two-state toggle switch widget that can select between two options. The user may drag the "thumb" back and forth to choose the selected option, or simply tap to toggle as if it were a checkbox. The text property controls the text displayed in the label for the switch, whereas the off and on text controls the text on the thumb. Similarly, the textAppearance and the related setTypeface() methods control the typeface and style of label text, whereas the switchTextAppearance and the related seSwitchTypeface() methods control that of the thumb.

The Android Developer Guide regarding toggle buttons also states, that

The ToggleButton and Switch controls are subclasses of CompoundButton and function in the same manner, so you can implement their behavior the same way.

201 questions
0
votes
2 answers

Implementing (switch\toggle button) depending on API level

My application will run on api level 9 devices or higher. Now i have a toggle_button on one of the layouts. I want to change this toggle button to switcher if the device is apilevel 14 or higher. How can i implement this? Sorry for my english.
Valentin Baryshev
  • 2,195
  • 3
  • 15
  • 24
0
votes
1 answer

Switch Text disable tapping

Is there anyway to disable tapping on the text of a Switch? Currently it toggles the switch which I don't want. I'm setting my switch text like messageSwitch.setText("Messaging Enabled");. This makes the entire switch view receiving taps of the…
Dunes Buggy
  • 1,779
  • 1
  • 21
  • 41
0
votes
2 answers

How to add listener to dynamic view in ExpandableListView?

I have an expandable list view. I use a custom adapter to load my own .xml layout. Each group has a Switch. I don't know how many groups will be displayed. Now I am wondering how to dynamically add a listener to each switch, in order to react on…
null
  • 1,369
  • 2
  • 18
  • 38
0
votes
0 answers

android - return int from onItemSelected using a spinner

I have conditional spinners that I'm using along with a switch case. i.e. Spinner1-choice1 will output Spinner2-a/b/c as options, and Spinner1-choice2 will output Spinner2-x/y/z. I'm trying to assign unique int identifiers to the parent spinner's…
0
votes
1 answer

Ellipsize text within switch in android

I have a switch and i need the text within the switch(Eg: ON/OFF) to be ellipsized if long. How can it be done?The following does not work!!
user584263
  • 375
  • 5
  • 18
0
votes
2 answers

Is it possible to use Switch widget in Android honeycomb 3.x?

It always give me the following exception in runtime: android.view.InflateException: Binary XML file exception line #291: Error inflating class android.widget.Switch However, I added the latest Android Support Library to my project but it did not…
0
votes
1 answer

Switch inside navigation drawer in android

I have a Switch inside a navigation drawer.Toggle happens only on tap.When i try to slide and toggle the Switch, the navigation drawer slides.What do i do? Switch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override …
user584263
  • 375
  • 5
  • 18
0
votes
1 answer

How to reduce the height of a thumb in a switch?

I am working on a Switch widget and I want to reduce the height of the thumb. By default the thumb's and the track's height are the same. But I want the thumb's height to be less than that of the track. Thanks in advance for the suggestions.
Saraschandraa
  • 478
  • 1
  • 10
  • 28
0
votes
1 answer

Android Switch thumb image stretched

I need a custom Switch in Android application. I'm using this code:
andreasperelli
  • 1,034
  • 2
  • 11
  • 40
0
votes
0 answers

Conflict between 2 libraries

I have a conflict with android-switch-backport and android-betterpickers because both override the style "switchStyle" and "switchPreferenceStyle". I want to use both of libraries (because the switch android-switch-backport have more possibilities…
0
votes
2 answers

android.widget.Switch cannot be cast to android.widget.ToggleButton

I got these simple lines of code: MainActivity: public class MainActivity extends FragmentActivity implements ActionBar.TabListener { (...) public void VehicleDeleteModus(View v){ boolean on = ((ToggleButton) v).isChecked(); (...) …
Fabian
  • 748
  • 2
  • 11
  • 20
0
votes
1 answer

Switch support in API 15

I am currently using the Switch Widget which supposedly came in API 14. My project is set to a min API of 15. I am trying to change the background of the Switch widget track OnCheckedChanged but i get an error that setTrackResource needs a minimum…
erik
  • 4,946
  • 13
  • 70
  • 120
0
votes
1 answer

Android Switch in ExpandableListView

I have an ExpandableListView with a custom adapter. Each parent (or group) has a TextView and each child (items) has a textview and a switch. My ChildModel has a String name (TextView) and a String[] choices (switch). However, I believe my layouts…
Nelson.b.austin
  • 3,080
  • 6
  • 37
  • 63
0
votes
1 answer

android listview of switches, do I need custom adapter?

I am creating a listview of Switch objects, Switch objects contain textview properties, do I need a custom adapter or can I just use a simple adapter?
CQM
  • 42,592
  • 75
  • 224
  • 366
0
votes
1 answer

android:track attibute for Switch doesn't work

Example: link android:track="@drawable/switch_bg" Eclipse outputs: error: No resource identifier found for attribute 'track' in package 'android' Manifest: This…
Forme
  • 301
  • 3
  • 16
1 2 3
13
14