@@ -5,10 +5,10 @@ Android Library for Custom Switches.
55[ Angad Singh] ( https://www.github.com/angads25 ) ([ @angads25 ] ( https://www.twitter.com/angads25 ) )
66
77### Benchmark:
8- [ ![ API] ( https://img.shields.io/badge/API-9 %2B-brightgreen.svg?style=flat )] ( https://android-arsenal.com/api?level=9 ) < a href = " http://www.methodscount.com/?lib=com.github.angads25%3Afilepicker%3A1.1.1 " >< img src = " https://img.shields.io/badge/Methods and size-271 | 43 KB-e91e63.svg " /></ a >
8+ [ ![ API] ( https://img.shields.io/badge/API-14 %2B-brightgreen.svg?style=flat )] ( https://android-arsenal.com/api?level=14 )
99
1010### Where to Find:
11- [ ![ Download] ( https://api.bintray.com/packages/angads25/maven/filepicker /images/download.svg ) ] ( https://bintray.com/angads25/maven/filepicker /_latestVersion ) [ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/com.github.angads25/filepicker /badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/com.github.angads25/filepicker ) [ ![ Android Arsenal ] ( https://img.shields.io/badge/Android%20Arsenal-FilePicker-blue.svg?style=flat )] ( http://android-arsenal.com/details/1/3950 )
11+ [ ![ Download] ( https://api.bintray.com/packages/angads25/maven/Toggle /images/download.svg )] ( https://bintray.com/angads25/maven/Toggle /_latestVersion ) [ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/com.github.angads25/toggle /badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/com.github.angads25/toggle )
1212
1313
1414### Installation
@@ -18,7 +18,37 @@ Android Library for Custom Switches.
1818 compile 'com.github.angads25:toggle:1.0.0'
1919```
2020
21+ ### Usage
22+
23+ 1 . Start by adding a Switch (eg. LabeledSwitch) in your xml layout as:
24+
25+ ``` xml
26+
27+ <com .github.angads25.toggle.LabeledSwitch
28+ android : id =" @+id/switch1"
29+ android : layout_width =" wrap_content"
30+ android : layout_height =" wrap_content"
31+ android : layout_margin =" 16dp"
32+ android : textSize =" 14sp"
33+ app : on =" false"
34+ app : colorBorder =" @color/colorAccent" />
35+ ```
36+
37+ 2. To the reference of Switch in your Activity/Fragment class and set a ToggleListener to it as below:
38+
39+ ```java
40+ LabeledSwitch labeledSwitch = findViewById(R.id.switch1);
41+ labeledSwitch.setOnToggledListener(new OnToggledListener() {
42+ @Override
43+ public void onSwitched(LabeledSwitch labeledSwitch, boolean isOn) {
44+ // Implement your switching logic here
45+ }
46+ });
47+ ```
48+ That's It. All your switching callbacks would be handled in onSwitched method, isOn will provide the current state of the switch.
49+
2150### Switches Available
2251
2352* Labeled Switch
2453
54+ 
0 commit comments