Questions tagged [android-togglebutton]

A toggle button allows the user to change a setting between two states.

A toggle button allows the user to change a setting between two states. It displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".

For more information, see the Toggle Buttons guide.

199 questions
1
vote
2 answers

Android Firestore set limit to 1 vote per user

I'm creating my first app from scratch which is a forum app on android and I've gotten to the upvoting/downvoting part of it. I have it set up to where my users can upvote downvote (similar to StackOverflow) however I don't know how to limit it to…
Cflux
  • 1,423
  • 3
  • 19
  • 39
1
vote
1 answer

Android toggle button save state custom listview

Hello friend i am new in android i want to know how to save ToggleButton state in custom ArrayAdapter i create custom ListView with help of ArrayAdapter now i want how save its state in Adapter here is my code pleae explain what logic used to…
1
vote
2 answers

How to make area editable/not editable using Togglebutton?

I was trying to make an area so when ToggleButton is on, you are able to toggle buttons within this area and if ToggleButon is off, you won't be able to toggle the buttons within this area. For this specific area I used a FrameLayout, so I can stack…
HartP
  • 13
  • 4
1
vote
0 answers

Distorted toggle button image

I have found several duplicate questions. I'm having exactly the same problem: Android Studio | How do I scale the image in ToggleButton? Android Toggle Button distorted view However, their problems haven't been solved yet so I just want to ask a…
user10634280
1
vote
2 answers

Why is there is strange padding/margin around toggle button?

It's a weird toggle button. As you can see in the picture I did not set any margin/padding, but it just has a small 2dp of margin/padding around the toggle button. I want to align it to right with the button group above, how should I do…
MarkL
  • 313
  • 1
  • 9
1
vote
1 answer

How can I turn on and off mobile data using toggle button?

Today I have done a task using toggle button. The mobile data needs to be turned on when I press the enable toggle button, and it should be turned off when I press the same button. I had done everything and when I press the enable button, the mobile…
Da1
  • 21
  • 1
  • 6
1
vote
1 answer

How to Store toogle button status in shared preference and load the status later in android?

The thing is I want to store my toogle button status in shared preference, so that I when I return to the application my toogle button wil stay in previous state. This is kind of something Do you want to use this. If user make the button enable that…
Tanvir Durlove
  • 768
  • 2
  • 9
  • 21
1
vote
0 answers

How can I make my ImageButton behave differently depending on ToggleButton status?

I am trying to add a toggle button, so that my image button switches the direction that it translates based on the status of the toggle button. However, I am running into problems when trying to add it to the media player, and when using the if…
1
vote
2 answers

ListView Adapter with ToggleButton Filters

I'm developing an Android app that has a list of 80+ "God" objects, each having a "ClassName" string attribute ("Warrior", "Hunter", "Assassin", etc.). I am trying to implement ToggleButtons that will filter the list by ClassName. Multiple filters…
1
vote
1 answer

ToggleButton rectangle containing an icon

I am trying to have a ToggleButton rectangle that contains an icon, once clicked the background should change color but the icon should remain visible. So far I'm able to have a rectangle change color on click like such:
Christopher
  • 139
  • 3
  • 11
1
vote
2 answers

How do we get and set same Toggle value while navigating from one screen(activity) to another activity?

My question is like in my activity 2 i have the screen like below. I am toggling two or more toggle button (activity 2) and going back(arrow) to activity 1. Now My question is how to save those value when navigating from activity 1 to activity 2…
Vikash Kumar
  • 395
  • 5
  • 17
1
vote
0 answers

Android ToggleButton drawing glitch on API 25

I'm facing this weird problem where I have a custom view (with custom drawing) overriding ToggleButton, and for some reason overriding the onDraw and draw methods do not prevent the parent class from drawing a part of it, which makes my view look…
androidseb
  • 1,257
  • 2
  • 14
  • 17
1
vote
4 answers

Changing background in other activities with a button

I have a problem. I have 3 activities (MainActivity, DetailsActivity, SettingsActivity) and in SettingsActivity I have a Togglebutton "Nightmode". What I want is, when the button is changed, change background of all three activities on gray…
user5655946
1
vote
1 answer

Android Studio - Drawer Toggle of the Toolbar not Opening the Drawer

Anyone know what I am doing wrong why my Drawer Toggle button of my Toolbar is not opening the Navigation Drawer? I am using the below code inside my onCreate Toolbar toolbar; NavigationView mNavigationView; DrawerLayout…
1
vote
1 answer

ToggleButton code in Android Studio unexpectedly crashes the App

My project is a music player that has a ToggleButton for play/pause. I tried to run a code in Android Studio, but it unexpectedly crashes the App. I am trying to follow up some tutorials on the internet and YouTube guides, but nothing works so…
Zeid Tisnes
  • 396
  • 5
  • 22