An open API service indexing awesome lists of open source software.

https://github.com/utsavdotpro/advanceswitch

An Android Switch widget with advance click and change handling.
https://github.com/utsavdotpro/advanceswitch

android android-library android-switch java ui-component

Last synced: about 2 months ago
JSON representation

An Android Switch widget with advance click and change handling.

Awesome Lists containing this project

README

          

[![](https://jitpack.io/v/u-barnwal/AdvanceSwitch.svg)](https://jitpack.io/#u-barnwal/AdvanceSwitch)
# AdvanceSwitch

An Android Switch widget based on AndroidX SwitchCompact with advance click and change handling.

## Sample

## Implementation
**Step 1:** Add to project level build.gradle

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

**Step 2:** Add to app level build.gradle

dependencies {
implementation 'com.github.u-barnwal:AdvanceSwitch:VERSION'
}
## How to use
**Step 1:** Create view



**Step 2:** Add change listener

@Override
protected void onCreate(Bundle savedInstanceState) {
...

AdvanceSwitch switchMain = findViewById(R.id.switchMain);

switchMain.setOnCheckedChangeListener((buttonView, isChecked) -> {
Toast.makeText(this, "Listened to change!", Toast.LENGTH_SHORT).show();
});
}

**Changing checked without triggering listener**

switchMain.setCheckedManually(true); // check
switchMain.setCheckedManually(false); // uncheck
switchMain.toggleManually(); // toggle

**Changing checked while triggering listener**

switchMain.setChecked(true); // check
switchMain.setChecked(false); // uncheck
switchMain.toggle(); // toggle

## Features

- Used just like default Switch widget
- Doesn't reserve the view tag (setTag() or getTag() are not being used).
- Easy to use
- Light weight

## Links
- Live example: https://transactionslistlite.isolpro.in