Comments (8)
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.
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.
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.
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.
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.
I will have a look at this this week end :)
See if I can figure it out.
from android-switch-backport.
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.
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)
- No titlebar crash the example HOT 1
- [Q] Is it possible to resize the Switch height to make it bigger? HOT 1
- [Q] Is it there a way to change the color of the ON button? HOT 1
- Track does not work in switch preference HOT 1
- Can't get the preference to show up! HOT 2
- Text color of switch not set correctly HOT 2
- Gradle build gets stuck after including repo and dependency HOT 3
- JRAF repo not responding HOT 9
- Rendering Problems HOT 1
- Attribute has already been defined exception when using lib with compile ('com.doomonafireball.betterpickers:library:1.5.2') HOT 14
- Customize text on switch and color HOT 4
- Problem to change thumb and track drawables HOT 1
- Nullpointerexception when used on Nexus4 HOT 2
- OnPreferenceChange return False, Switch Changes HOT 3
- NullPointerException HOT 8
- Publish artefact on maven central instead on your own nexus HOT 3
- Publish on Maven Central or JCenter HOT 4
- JRAF.org is down HOT 3
- Incompatible with Support Library material Switch theme HOT 4
- Getting Null pointer exception HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-switch-backport.