StateButton is an android library that the button component has a boolean value.
Add this to your root build.gradle
file.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add this to your app build.gradle
file.
dependencies {
...
compile 'com.github.yuzumone:StateButton:0.1.2'
}
<net.yuzumone.statebutton.StateButton
android:id="@+id/state_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<net.yuzumone.statebutton.StateButton
app:state="true"
app:trueText="True"
app:falseText="False"
/>
To set a init state of the button you use the setState functionality via xml or java. Default value is false.
app:state="true"
or
app:state="false"
stateButton.setState(true);
or
stateButton.setState(false);
To set text of the button you use the setTrueText or setFalseText functionality via xml or java. You can use String or String Resource.
app:trueText="True"
or
app:trueText="@string/true_string"
stateButton.setTrueText("True");
or
stateButton.setTrueText(R.string.true_string);
By setting a listener you will receive events accroding to the state.
stateButton.setOnStateButtonListener(new OnStateButtonListener() {
@Override
public void trued(StateButton stateButton) {
}
@Override
public void falsed(StateButton stateButton) {
}
});
Copyright 2017 yuzumone
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.