riccardomoro / rmswitch Goto Github PK
View Code? Open in Web Editor NEWA simple and customizable two or three states Switch View
A simple and customizable two or three states Switch View
When I call setChecked inside a RecyclerView, the animation triggers when I don't want it to. Can you please make a method such as setChecked(boolean checked, boolean animate)?
android switch loop does a iteration in 3... if you are calling an api it will call it 3 times, toasting 3 times. after the second time the toggle goes from on - off - on again.
When using the RMSwitch with a ViewPager and a RecyclerView, the switches on the adjacent screen are showing incorrectly. The drawables are rendered incorrectly and clicking it does not move to the other side. See the attached picture,
The workaround is to reload the entire recyclerview by calling notifyDataSetChanged() but I prefer not to do that since it has a visible flash in the data.
I have a RecyclerView
, each item have a RMTristateSwitch
, when update all data, I call to adapter.notifyDataSetChanged()
and all RMTristateSwitch
do an animation and it's very ugly.
¿How can I disabled this animation on reload?
....android E/RMSwitch: Paddings
....android E/RMSwitch: Margins
....android E/RMSwitch: Paddings
....android E/RMSwitch: Margins
....android E/RMSwitch: Paddings
....android E/RMSwitch: Margins
....android E/RMSwitch: Paddings
....android E/RMSwitch: Margins
....android E/RMSwitch: Paddings
....android E/RMSwitch: Margins
Title says it all
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rm.switchsample/com.rm.switchsample.ActivityMain}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.rm.rmswitch.RMSwitch
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.rm.rmswitch.RMSwitch
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.rm.rmswitch.RMSwitch
Caused by: java.lang.reflect.InvocationTargetException
For the record, you can get this library from jitpack using com.github.RiccardoMoro:RMSwitch:1.2.3
It will be great to have a possibility to add custom background to the switch. Or have material switch background with possibility to add drawable to left and right.
*Update library Build Tools and Target SDK.
This is the log:
11-21 10:10:47.451 4055-4055/com.rm.switchsample E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1160672)
11-21 10:10:47.453 4055-4055/com.rm.switchsample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rm.switchsample, PID: 4055
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1160672 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3755)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.os.TransactionTooLargeException: data parcel size 1160672 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3628)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3747)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
It is working fine when I am not using image for checked state but when I use is it is giving error.
I am using it in Toolbar the code is following
<com.rm.rmswitch.RMSwitch
android:id="@+id/btnAvailability"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/margin_8dp"
app:checked="true"
app:switchBkgCheckedColor="@color/colorWhite"
app:switchBkgNotCheckedColor="@color/colorWhite"
app:switchToggleCheckedColor="@color/colorGreen"
app:switchToggleCheckedImage="@drawable/confirm"
app:switchToggleNotCheckedImage="@drawable/cancel"
app:switchToggleNotCheckedColor="@color/colorPrimary" />
Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class com.rm.rmswitch.RMSwitch
at android.view.LayoutInflater.createView(LayoutInflater.java:649)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:768)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:975)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:842)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable/confirm.png"
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parse(Integer.java:410)
at java.lang.Integer.parseInt(Integer.java:367)
at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:133)
at android.content.res.TypedArray.getInt(TypedArray.java:357)
at com.rm.rmswitch.RMAbstractSwitch.(RMAbstractSwitch.java:119)
at com.rm.rmswitch.RMSwitch.(RMSwitch.java:87)
at com.rm.rmswitch.RMSwitch.(RMSwitch.java:83)
There are still devices below, and this is only switches.
Maybe set it to API 9 , or at least 14 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.