RMSwitch
来源:互联网 发布:淘宝11.11抢拍技巧 编辑:程序博客网 时间:2024/04/27 18:21
RMSwitch
项目地址:RiccardoMoro/RMSwitch
简介:A simple and customizable Switch View
A simple View that works like a switch, but with more customizations.
With the option to choose between two or three states. (from v1.1.0)
[Changelog] (CHANGELOG.md)
Download
Gradle:
compile 'com.rm:rmswitch:1.1.1'
Usage
To use them, just add this to your layout file
<!-- Two states switch --> <com.rm.rmswitch.RMSwitch android:id="@+id/your_id" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <!-- Three states switch --> <com.rm.rmswitch.RMTristateSwitch android:id="@+id/your_id2" android:layout_width="wrap_content" android:layout_height="wrap_content" />
... if you need to use this View's custom xml attributes (shown in a table below) do not forget to add this to your root layout
xmlns:app="http://schemas.android.com/apk/res-auto"
To see how it looks in the preview screen of Android Studio, build your project first
And this in your Activity
public class MainActivity extends AppCompatActivity { RMSwitch mSwitch; RMTristateSwitch mTristateSwitch; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSwitch = (RMSwitch) findViewById(R.id.your_id); mTristateSwitch = (RMTristateSwitch) findViewById(R.id.your_id2); // Add a Switch state observer mSwitch.addSwitchObserver(new RMSwitch.RMSwitchObserver() { @Override public void onCheckStateChange(boolean isChecked) { Toast.makeText(MainActivity.this, "Switch state: " + (isChecked ? "checked" : "not checked"), Toast.LENGTH_LONG) .show(); } }); mTristateSwitch.addSwitchObserver(new RMTristateSwitch.RMTristateSwitchObserver() { @Override public void onCheckStateChange(@RMTristateSwitch.State int state) { Toast .makeText(MainActivity.this, state == RMTristateSwitch.STATE_LEFT ? "Left" : state == RMTristateSwitch.STATE_MIDDLE ? "Middle" : "Right", Toast.LENGTH_SHORT).show(); } }); }}
0 0
- RMSwitch
- 8-求倒数和
- 【MySQL】Inception备份库表数据中文乱码解决
- Codeforces Round #377 (Div. 2) A. Buy a Shovel
- 二、Android 解决在ListView历史复用中Edittext数据显示混乱
- Android Fragment 真正的完全解析(下)
- RMSwitch
- webstorm+nodejs+JetBrains IDE Support+chrome打造前端开发神器
- libevent学习笔记【使用篇】——9. Libevent和DNS解析
- [Kafka-users] Producer not distributing across all partitions
- 当你迷茫时,请努力做好现在的工作
- arm交叉编译器gnueabi、none-eabi、arm-eabi、gnueabihf、gnueabi区别
- bootstrap nav nav-tabs 选项卡 的使用实例
- JavaScript基础(对象)
- iOS - 关于上传手机本地图片到网页的问题