android-togglebutton

Is there a way to programmatically set src image for ToggleButton?

佐手、 提交于 2019-12-11 00:36:23
问题 I am using a ToggleButton with an image. The image is 16x16, however, I want the button to be 50x50 so that when users click around the image even then the action is taken. This is how I'm avoiding the fat finger problem. This is how my ToggleButton is in the XML <ToggleButton android:id="@+id/fav" android:layout_width="50dp" android:layout_height="50dp" android:background="#FFFFFF" android:gravity="center" android:focusable="false" android:layout_marginRight="10dp" android:padding="15dp" />

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

EditText addTextChangedListener only for user input

十年热恋 提交于 2019-12-01 20:05:01
问题 I have an EditText where I listen for changes in text: editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} @Override public void afterTextChanged(Editable s) { // do stuff } }); This works fine so far, if I type something in the EditText, things in afterTextChanged() are executed. Now, in the same activity I have a

How to know whether user has changed the state of toggle button?

偶尔善良 提交于 2019-11-28 10:56:36
I have ten toggle buttons. I want to save the state of five of those buttons when clicking the home button. But I want to save it only if the user has made a change to any of the buttons' state. Is there any way to know the change in states without using setOnClickListener()? I have done the following, its not so nice, but it works: ttsButton = (ToggleButton) findViewById(R.id.solution_ttsbutton); ttsButton.setOnCheckedChangeListener(toggleButtonChangeListener); ... // gets called, if the button state changes final CompoundButton.OnCheckedChangeListener toggleButtonChangeListener = new

How to know whether user has changed the state of toggle button?

微笑、不失礼 提交于 2019-11-27 03:55:01
问题 I have ten toggle buttons. I want to save the state of five of those buttons when clicking the home button. But I want to save it only if the user has made a change to any of the buttons' state. Is there any way to know the change in states without using setOnClickListener()? 回答1: I have done the following, its not so nice, but it works: ttsButton = (ToggleButton) findViewById(R.id.solution_ttsbutton); ttsButton.setOnCheckedChangeListener(toggleButtonChangeListener); ... // gets called, if