Git Product home page Git Product logo

android-switch-backport's People

Contributors

ahaeber avatar barbeau avatar bod avatar googolmo avatar intrications avatar rock3r avatar wkovacs64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-switch-backport's Issues

Add Maven support

Would be great if this were available via maven so we could add the dependency to our pom.xml and then just start developing.

Android 4.1.2 can not run?

11-20 14:19:04.128: E/AndroidRuntime(10332): FATAL EXCEPTION: main
11-20 14:19:04.128: E/AndroidRuntime(10332): java.lang.NullPointerException
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.text.Layout.getDesiredWidth(Layout.java:67)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:378)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:306)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.View.measure(View.java:15172)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.View.measure(View.java:15172)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.View.measure(View.java:15172)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.View.measure(View.java:15172)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.View.measure(View.java:15172)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1850)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1102)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1275)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.Choreographer.doFrame(Choreographer.java:525)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.os.Handler.handleCallback(Handler.java:615)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.os.Looper.loop(Looper.java:137)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at android.app.ActivityThread.main(ActivityThread.java:4745)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at java.lang.reflect.Method.invokeNative(Native Method)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at java.lang.reflect.Method.invoke(Method.java:511)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 14:19:04.128: E/AndroidRuntime(10332):    at dalvik.system.NativeStart.main(Native Method)
11-20 14:22:38.050: E/AndroidRuntime(12344): FATAL EXCEPTION: main
11-20 14:22:38.050: E/AndroidRuntime(12344): java.lang.NullPointerException
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.text.Layout.getDesiredWidth(Layout.java:67)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:378)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:306)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.View.measure(View.java:15172)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.View.measure(View.java:15172)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.View.measure(View.java:15172)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.View.measure(View.java:15172)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.View.measure(View.java:15172)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1850)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1102)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1275)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.Choreographer.doFrame(Choreographer.java:525)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.os.Handler.handleCallback(Handler.java:615)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.os.Looper.loop(Looper.java:137)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at android.app.ActivityThread.main(ActivityThread.java:4745)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at java.lang.reflect.Method.invokeNative(Native Method)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at java.lang.reflect.Method.invoke(Method.java:511)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 14:22:38.050: E/AndroidRuntime(12344):    at dalvik.system.NativeStart.main(Native Method)
11-20 14:24:08.136: E/AndroidRuntime(12973): FATAL EXCEPTION: main
11-20 14:24:08.136: E/AndroidRuntime(12973): java.lang.NullPointerException
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.text.Layout.getDesiredWidth(Layout.java:67)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:378)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:306)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.View.measure(View.java:15172)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.View.measure(View.java:15172)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.View.measure(View.java:15172)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.View.measure(View.java:15172)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.View.measure(View.java:15172)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1850)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1102)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1275)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.Choreographer.doFrame(Choreographer.java:525)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.os.Handler.handleCallback(Handler.java:615)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.os.Looper.loop(Looper.java:137)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at android.app.ActivityThread.main(ActivityThread.java:4745)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at java.lang.reflect.Method.invokeNative(Native Method)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at java.lang.reflect.Method.invoke(Method.java:511)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 14:24:08.136: E/AndroidRuntime(12973):    at dalvik.system.NativeStart.main(Native Method)

Problems with HoloEverywhere

Hello,

I'm trying to use this widget with HoloEverywhere (https://github.com/Prototik/HoloEverywhere), and when I try to run my app the console shows these errors:

android-switch-backport-master\library\res\values\attrs.xml:61: error: Attribute "thumb" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:63: error: Attribute "track" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:65: error: Attribute "textOn" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:67: error: Attribute "textOff" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:69: error: Attribute "thumbTextPadding" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:71: error: Attribute "switchTextAppearance" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:73: error: Attribute "switchMinWidth" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:75: error: Attribute "switchPadding" has already been defined
android-switch-backport-master\library\res\values\attrs.xml:78: error: Attribute "switchStyle" has already been defined

How can this be solved?

Thanks!

Problem to change thumb and track drawables

Hi,

I generated my custom style of Switch in this site : http://android-holo-colors.com/
I added the drawable folders to my project and I inflated the Custom Switch like this :

<org.jraf.android.backport.switchwidget.Switch xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.myproject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:thumb="@drawable/switch_inner_holo_light"
app:track="@drawable/switch_track_holo_light" />

My custom style is applied correctly on Android 2.3 BUT NOT on Android 4.2 like Samsung Galaxy S4.

I also tried to create "drawable-xxx-v16" folders with the drawables but doesn't work too.
Where is my problem ?

Soory for my English, I am French.
Thanks you for your help.

Widget Image Absent.

Tried to use library.
Done everything as written in readme, everything works except no switch widget visible, the state of preference changed by just clicking no switch widget is seen. Tried on ICS JB devices and GB emulator

Lint warnings

Hi,

I've just cloned master to see if it could work as I need, and I got several warnings, so if you could please resolve why it is done this way.

  1. Not needed @SuppressWarnings in Switch.java:99
99:    @SuppressWarnings("hiding")
100:    private final Rect mTempRect = new Rect();
  1. Unused boolean private member mSendClickAccessibilityEvent in TwoStatePreference.java:49
49:    private boolean mSendClickAccessibilityEvent;
...
73:    mSendClickAccessibilityEvent = true;

as far as this member is private, and only one assignment is done in onClick() and no further use, it is probably just leftover

Call OnPreferenceClickListener when inner Switch is clicked.

When binding SwitchPreference to a OnPreferenceClickListener, if the user clicks on the Switch instead of the rest of the widget (ie Label), the listener is not being called.
Modifying the CompoundButton.OnCheckedChangeListener associated to the inner Switch fixes the issue:

private class Listener implements CompoundButton.OnCheckedChangeListener {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (!callChangeListener(isChecked)) {
            // Listener didn't like it, change it back.
            // CompoundButton will make sure we don't recurse.
            buttonView.setChecked(!isChecked);
            return;
        }
        SwitchPreference.this.setChecked(isChecked);
        if (getOnPreferenceClickListener() != null) {
            getOnPreferenceClickListener().onPreferenceClick(SwitchPreference.this);
        }
    }
}

I believe that if the Listener returns false, should rollback the checked state as on the above block.

NullPointerException

java.lang.NullPointerException
at android.text.Layout.getDesiredWidth(Layout.java:67)
at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:350)
at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:302)
at android.view.View.measure(View.java:16497)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16497)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
at android.view.View.measure(View.java:16497)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

Can't get the preference to show up!

Help! I've spent way too much time trying to get the sample to work (which does great btw!) and then trying to get my app to work with this library.

I am apparently missing something simple. When the preferences screen loads I can click on the preference with the switch and it changes, but there is NO UI displayed in my app. It shows up JUST FINE in the demo.

It might be useful to know that I am using ActionBarSherlock, could be a conflict I guess with that library in the resources somehow?

I have had NO luck at all with any of the information that has been provided through logcat. It is hard to even know what to be looking for. There is certainly no glaring exceptions that are being thrown.

Any pointers would be greatly appreciated before I give up and go back to boring checkboxes. :-(

Using this library in both pre and post ICS

Hi.

My project should run on 2.3.3+ devices, all the way up to and including JB. I have added your library to get the nice looking Switch control and it works nicely. The only issue I have is that on my JB device, the look of the Switch is not quite right; the "thumb" is a rectangle instead of having slanted sides; it is perfectly functional but on 2.3.3, it looks like the standard ICS Switch but on post ICS, it doesn't.

How should I do the theme so that it works nicely on pre and post ICS?

Thanks for writing this library,
Ali.

Rename the resources with a library specific prefix

Project resources override library resources, but only specifically with respect to qualifiers.
For instance, project/drawable/xxx.png overrides lib/drawable/xxx.png but not lib/drawable-v16/xxx.png

The easiest way to deal with this is to rename the resources with a library specific prefix, to avoid conflicts.

Getting Null pointer exception

Failed to find style 'asb_switchStyle' in current theme
java.lang.NullPointerException
Exception details are logged in Window > Show View > Error Log

java.lang.NullPointerException
at android.text.Layout.getDesiredWidth(Layout.java:68)
at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:350)
at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:302)
at android.view.View.measure(View.java:17430)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
at android.view.View.measure(View.java:17430)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17430)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17430)

I added the style as described as follows :

<style name="AppTheme" parent="@android:style/Theme"> true false false @null @style/Widget.Holo.CompoundButton.Switch </style>

stil i ma getting the error . I am assuming i am not describing the style properly can you please help.

Nullpointerexception when used on Nexus4

Sorry, I have no time to investigate further. Here is a stacktrace. Someone else mentioned this on stackoverflow, too... Does not appear in the emulator.

04-28 01:10:15.335: E/AndroidRuntime(30182): FATAL EXCEPTION: main
04-28 01:10:15.335: E/AndroidRuntime(30182): Process: de.t_animal.journeyapp, PID: 30182
04-28 01:10:15.335: E/AndroidRuntime(30182): java.lang.NullPointerException
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.text.Layout.getDesiredWidth(Layout.java:67)
04-28 01:10:15.335: E/AndroidRuntime(30182): at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:350)
04-28 01:10:15.335: E/AndroidRuntime(30182): at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:302)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1451)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
04-28 01:10:15.335: E/AndroidRuntime(30182): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-28 01:10:15.335: E/AndroidRuntime(30182): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.View.measure(View.java:16497)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.Choreographer.doFrame(Choreographer.java:544)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.os.Handler.handleCallback(Handler.java:733)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.os.Handler.dispatchMessage(Handler.java:95)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.os.Looper.loop(Looper.java:136)
04-28 01:10:15.335: E/AndroidRuntime(30182): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-28 01:10:15.335: E/AndroidRuntime(30182): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 01:10:15.335: E/AndroidRuntime(30182): at java.lang.reflect.Method.invoke(Method.java:515)
04-28 01:10:15.335: E/AndroidRuntime(30182): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-28 01:10:15.335: E/AndroidRuntime(30182): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-28 01:10:15.335: E/AndroidRuntime(30182): at dalvik.system.NativeStart.main(Native Method)

Incompatible with Support Library material Switch theme

In Support Library >= 21 Widget.AppCompat.CompoundButton.Switch provides material theming for SwitchCompat. Unfortunately, it does not work as drop-in replacement for Widget.Holo.CompoundButton.Switch if used as value for asb_switchStyle: application crashes with NullPointerException:

            at org.jraf.android.backport.switchwidget.Switch.onMeasure(Unknown Source)
            at android.view.View.measure(View.java:16772)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5139)
            at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
            at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
            at android.view.View.measure(View.java:16772)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5139)
            at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
            at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052)
            at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
            at android.view.View.measure(View.java:16772)
            at android.widget.ListView.setupChild(ListView.java:1870)
            at android.widget.ListView.makeAndAddView(ListView.java:1793)
            at android.widget.ListView.fillDown(ListView.java:691)
            at android.widget.ListView.fillFromTop(ListView.java:752)
            at android.widget.ListView.layoutChildren(ListView.java:1630)
            at android.widget.AbsListView.onLayout(AbsListView.java:2136)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1660)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1436)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:15092)
            at android.view.ViewGroup.layout(ViewGroup.java:4645)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2014)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1771)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1026)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5776)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:771)
            at android.view.Choreographer.doCallbacks(Choreographer.java:574)
            at android.view.Choreographer.doFrame(Choreographer.java:544)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:757)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:149)
            at android.app.ActivityThread.main(ActivityThread.java:5268)

OnPreferenceChange return False, Switch Changes

When an OnPreferenceChangeListener returns false the switch should not be triggered.

What currently happens is the switch is moved to the ON position, but remains dull.
The switch correctly doesnt lightup but it shouldnt even move position. This gives the illusion that the switch is On, when in fact it is not.

This was verified against the built-in switch, with the backport using the default style.

Custom images are ignored

This a really weird bug and it's probably not an issue with the library itself, but more of an issue with how the apk is compiled.

I've generated styles from http://android-holo-colors.com/ and I'm trying to use them to override the default Switch styles. The images that it generates are using the same names as the images provided by this library.

When I install my app on my Nexus One running 2.3.6, everything is fine and it's using my custom images. When I install the app on any of my 4.2 devices, it uses the default blue images.

Do you have any idea how to get this to work without having to rename all of my images? I've tried changing the ordering in the .classpath but to no avail.

Thanks!

Customize text on switch and color

Hi,

I've managed to switch the background color from blue to green but now I want to change the text color?

          <org.jraf.android.backport.switchwidget.Switch
                        android:id="@+id/th"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:thumb="@drawable/apptheme_switch_inner_holo_light"
                        app:track="@drawable/apptheme_switch_track_holo_light"
                        app:textOn="@string/switch_yes"
                        app:textOff="@string/switch_no"
                        android:textColor="#000000"
                        />

But it isn't working.

NPE on Android 2.3.3

Device: LG Optimus
Android version 2.3.3

I'm inflating the xml in a customView of my actionbar. It works on 4.0 but not on 2.3.3

Java code:
View mActionBarView = getLayoutInflater().inflate(R.layout.custom_switch, null);
mActionBarView.findViewById(R.id.switch_server);
getSupportActionBar().setCustomView(mActionBarView);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM |
ActionBar.DISPLAY_SHOW_HOME|ActionBar.DISPLAY_USE_LOGO|ActionBar.DISPLAY_SHOW_TITLE);

xml:

<org.jraf.android.backport.switchwidget.Switch
    android:id="@+id/switch_server"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
Stack trace: java.lang.NullPointerException at android.text.Layout.getDesiredWidth(Layout.java:67) at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:378) at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:306) at android.view.View.measure(View.java:8313) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:581) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:365) at android.view.View.measure(View.java:8313) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at android.view.View.measure(View.java:8313) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017) at android.widget.LinearLayout.measureVertical(LinearLayout.java:386) at android.widget.LinearLayout.onMeasure(LinearLayout.java:309) at android.view.View.measure(View.java:8313) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)

Gradle build gets stuck after including repo and dependency

I used the Gradle instructions. After adding the repo and dependency the Gradle build process gets stuck on "compiling dependencies". After I took out the repo and dependency Gradle built correctly. I am using Android Studio 0.4.3, and Gradle 1.9.

Android Studio- Rendering problems

I am getting the following error in the latest Android Studio build, when trying to use the back-ported switch. I get this when I am in my layout view, and the sample gui is showing on the right.

image

Rendering Problems

Hello,

After adding library to android studio as submodle and using switch in layout, I got "Rendering Problem" in preview window. Here is the stacktrace:

Rendering Problems java.lang.NullPointerException   
at android.text.Layout.getDesiredWidth(Layout.java:67)   
at  org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:350)   
at  org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:302)   
at  android.view.View.measure(View.java:16458)   
at  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)   
at  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)   
at  android.widget.LinearLayout.measureVertical(LinearLayout.java:695)   
at  android.widget.LinearLayout.onMeasure(LinearLayout.java:588)   
at  android.view.View.measure(View.java:16458)   
at  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)   
at  android.widget.FrameLayout.onMeasure(FrameLayout.java:310)   
at  android.view.View.measure(View.java:16458)   
at  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)   
at  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)   
at  android.widget.LinearLayout.measureVertical(LinearLayout.java:695)   
at  android.widget.LinearLayout.onMeasure(LinearLayout.java:588)   
at  android.view.View.measure(View.java:16458)   
at  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)   
at  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)   
at  android.widget.LinearLayout.measureVertical(LinearLayout.java:695)   
at  android.widget.LinearLayout.onMeasure(LinearLayout.java:588)   
at  android.view.View.measure(View.java:16458)

I my layout I simply put Switch, just like in sample.

There was also a problem with using appcompat library, because there was name clash with styles, and I changed following lines in attrs.xml:

 <declare-styleable name="Theme">
        <attr name="switchStyle" format="reference" />
        <attr name="switchPreferenceStyle" format="reference" />
    </declare-styleable>

to

 <declare-styleable name="SwitchTheme">
        <attr name="switchStyle" format="reference" />
        <attr name="switchPreferenceStyle" format="reference" />
    </declare-styleable>

This only happens in editor, since switch i working fine, but is rather annoying, because it prevents your layout from being displayed

ClassNotFoundException for org.jraf.android.backport.switchwidget.SwitchPreference

When using SwitchPreference in a preference xml file it crashes with a ClassNotFoundException when trying to resolve SwitchPreference.

Inspecting the AAR file and the classes.jar inside it shows that Dalvik is correct - there is no SwitchPreference.class present. Apparently ProGuard renames the SwitchPreference class to a.class in the AAR file.

Stack trace (replaced original package name with a.b.c):

12-10 11:18:58.578  27807-27913/a.b.c.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{a.b.c.android/a.b.c.android.settings.SettingActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class org.jraf.android.backport.switchwidget.SwitchPreference
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
            at android.app.ActivityThread.access$600(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:213)
            at android.app.ActivityThread.main(ActivityThread.java:4787)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class org.jraf.android.backport.switchwidget.SwitchPreference
            at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
            at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
            at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
            at android.preference.GenericInflater.inflate(GenericInflater.java:326)
            at android.preference.GenericInflater.inflate(GenericInflater.java:263)
            at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:269)
            at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:1418)
            at a.b.c.android.settings.SettingActivity.onCreate(SettingActivity.java:78)
            at android.app.Activity.performCreate(Activity.java:5008)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
            at android.app.ActivityThread.access$600(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:213)
            at android.app.ActivityThread.main(ActivityThread.java:4787)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassNotFoundException: org.jraf.android.backport.switchwidget.SwitchPreference
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
            at android.preference.GenericInflater.createItem(GenericInflater.java:375)
            at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
            at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
            at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
            at android.preference.GenericInflater.inflate(GenericInflater.java:326)
            at android.preference.GenericInflater.inflate(GenericInflater.java:263)
            at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:269)
            at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:1418)
            at a.b.c.android.settings.SettingActivity.onCreate(SettingActivity.java:78)
            at android.app.Activity.performCreate(Activity.java:5008)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
            at android.app.ActivityThread.access$600(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:213)
            at android.app.ActivityThread.main(ActivityThread.java:4787)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)

Text color of switch not set correctly

I am a first time user of the switch backport. Thnx for making this code available.

I have trouble getting the text to appear correctly. In my sample project the text has not color (is just grey). This means that the "OFF" state text is not readable since the text is the same color as as the grey background. This is different from the sample app that comes with the switch backport where text is displayed in a light grey.

I am unable to set the text color myself with xml attributes.

When I comment out lines 178-184 from Switch.java, text is displayed correctly:

        colors = appearance.getColorStateList(R.styleable.Android_android_textColor);
        if (colors != null) {
            mTextColors = colors;
        } else {
            // If no color set in TextAppearance, default to the view's textColor
            mTextColors = getTextColors();
        }

into

        //colors = appearance.getColorStateList(R.styleable.Android_android_textColor);
       // if (colors != null) {
       //     mTextColors = colors;
       // } else {
            // If no color set in TextAppearance, default to the view's textColor
            mTextColors = getTextColors();
        //}

Is there an obvious thing that I am doing wrong here?

Can't import Switch

I'm trying to use this library using Gradle. I imported it in the gradle file like so:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}

apply plugin: 'android'

allprojects {
    repositories {
        mavenCentral()
        maven {
            url "http://JRAF.org/static/maven/2"
        }
    }
}

dependencies {
    compile project(':OurProject')
    compile (''org.jraf:android-switch-backport:1.1')
    instrumentTestCompile(files('libs/espresso-1.0-SNAPSHOT-bundled.jar'))
}

I then try to import the Switch class in my fragment using the following line:

import org.jraf.android.backport.switchwidget.Switch;

The strange thing is that it knows the whole part of this url up until the actual class. So it reconises org.jraf.android.backport.switchwidget., but it only doesn't know the Switch class.

When I try to use it in my xml file like so:

<org.jraf.android.backport.switchwidget.Switch
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

I get an error saying it can't find R anymore (i.e.: R doesn't build anymore because the use of the Switch in my xml creates an error).

I'm using the Android Studio IDE. Any ideas how I could solve this?

Any help would be very very welcome!

Track does not work in switch preference

Hi, I want to change the background of switch in preference but after set app:track with my custom background, it does not work.

Have you seen similar issue before? And How do I fix this? I have no problem when I set in regular switch

Thumb drawable being resized

Hi there,

I've customised the track and thumb with selector drawables. The switch works and I use wrap_content for the width and height.

However, the library is resizing the thumb, so it looks more like an egg than the desired circle. Is there something I need to set?

Cheers,

John
screen shot 2013-09-02 at 14 08 36

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.