Giter VIP home page Giter VIP logo

Comments (8)

BoD avatar BoD commented on August 22, 2024

I have seen this reported several times already but never could reproduce it.
Can you tell me which version of Android your project is targeting?

from android-switch-backport.

Arise avatar Arise commented on August 22, 2024

Running CyanogenMod 10, JellyBean.
uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"

14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime FATAL EXCEPTION: main
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime java.lang.NullPointerException
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.text.Layout.getDesiredWidth(Layout.java:67)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at org.jraf.android.backport.switchwidget.Switch.makeLayout(Switch.java:378)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at org.jraf.android.backport.switchwidget.Switch.onMeasure(Switch.java:306)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.View.measure(View.java:15172)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2768)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1850)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1102)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1275)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.Choreographer.doCallbacks(Choreographer.java:555)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.Choreographer.doFrame(Choreographer.java:525)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.os.Handler.handleCallback(Handler.java:615)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:92)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.os.Looper.loop(Looper.java:137)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:4950)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at java.lang.reflect.Method.invokeNative(Native Method)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at java.lang.reflect.Method.invoke(Method.java:511)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
14:52:25.687 11540 com.tssw.admin ERROR AndroidRuntime at dalvik.system.NativeStart.main(Native Method)

from android-switch-backport.

crossle avatar crossle commented on August 22, 2024

I known i forgot style (eg.. style.xml more...values-v14 forgot )

<org.jraf.android.backport.switchwidget.Switch
    android:layout_width="wrap_content"
    style="@style/Widget.Holo.CompoundButton.Switch"
    android:layout_height="wrap_content" />

The error occured when have no style attr....
you can use

  style="@style/Widget.Holo.CompoundButton.Switch"

as default

from android-switch-backport.

Arise avatar Arise commented on August 22, 2024

Set up some breakpoints and it seems the solution from here solves the issue.

Other bug report on NPE on Android 2.3.3

Don't understand if there is something wrong, or just a wrong way to fix a problem, but it worked for me.

However, now I've found another issue. The switcher is stuck, it stays on OFF no matter what, it doesn't move.

from android-switch-backport.

crossle avatar crossle commented on August 22, 2024

@Arise

I found the param text is null of the function...

 private Layout makeLayout(CharSequence text) {
    return new StaticLayout(text, mTextPaint, (int) Math.ceil(Layout.getDesiredWidth(text, mTextPaint)),   Layout.Alignment.ALIGN_NORMAL, 1.f, 0, true);
}

The param from styleable text_on text_off ... so need style(ps: your style.xml may have many... )

mTextOn = a.getText(R.styleable.Switch_textOn);
mTextOff = a.getText(R.styleable.Switch_textOff);

from android-switch-backport.

BoD avatar BoD commented on August 22, 2024

I will have a look at this this week end :)
See if I can figure it out.

from android-switch-backport.

smarek avatar smarek commented on August 22, 2024

Any progress here? I'd like to use it in project but I see some heavy development for latest Android versions is necessary ...

from android-switch-backport.

BoD avatar BoD commented on August 22, 2024

I just checked.
It seems that you are not using the theme in your Activity or Application.
I just updated the readme file to clarify this point.
Please tell me if you are still having problems after updating your manifest.

from android-switch-backport.

Related Issues (20)

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.