Comments (11)
My Bad for ActionBarSherlock I was overriding the default theme. Adding shareStyle to Sherlock theme.
<style name="LocalTheme" parent="Theme.Sherlock.Light"> @style/Widget.Holo.Light.CompoundButton.Switch </style>from android-switch-backport.
I'm getting the same exception but not sure what Hemanshu did exactly to fix it.
My Activity uses
android:theme="@style/Theme.NoAudibleSelection"
and this theme is defined as
<style name="Theme.NoAudibleSelection" parent="android:Theme.NoTitleBar.Fullscreen">
<item name="android:soundEffectsEnabled">false</item>
<item name="switchStyle">@style/Widget.Holo.CompoundButton.Switch</item>
</style>
from android-switch-backport.
Try parent="@android:style/Theme.NoTitleBar.Fullscreen"
from android-switch-backport.
Thanks for your quick reply. It started working all by itself without any changes when I restarted Eclipse. Was having a "Missing styles. Is the correct theme chosen for this layout?" error in the layout design GUI and now it seems to work OK. I'll comment if I figure out the real reason behind it.
from android-switch-backport.
I'm having this same issue but in a blank app. Target version is 4.0.3 while min version is 2.3.3. Same exact error.
from android-switch-backport.
Sorry, I wan't able to find out the exact reason, I just used Clean Project in Eclipse and also restarted it and it stopped crashing with no code modifications.
from android-switch-backport.
Damn, it has to be another thing... I have cleaned up all this stuff and no luck. Gonna create a new project now and see if it's working.
EDIT: New project and not working. Here is the detail of what I'm doing:
- My activity layout (relative layout):
<org.jraf.android.backport.switchwidget.Switch
android:id="@+id/switch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Really hope I'm missing something.
from android-switch-backport.
To all of you who cannot get this to work:
Are you using Eclipse, or another IDE?
from android-switch-backport.
Eclipse. Although I finally solved the problem, have been quite busy lately... sorry for not posting back.
The problem was that for some reason, the style was not found, causing the switch to crush on load. Here I drop you a couple of lines:
In the constructor
public Switch(Context context, AttributeSet attrs, int defStyle) {
I changed the line
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Switch, defStyle, 0);
to
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Switch, defStyle, R.style.Widget_Holo_CompoundButton_Switch);
To force it getting the style. If I didn't do this the switch styles were'nt found in the typedarray and a nullpointer was thrown.
Hope this helps.
from android-switch-backport.
Just as a follow up, make sure you are actually using the theme that you declare! To do that you must reference it in your AndroidManifest.xml. I just updated the readme file to clarify this. Hope this helps.
from android-switch-backport.
I'm having the same issue. I'm using Switch in a custom Dialog. Solution from cbmarc solved it for me.
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.