While there is now RadioButton Preference widget in Android, you can use the existing CheckBoxPreference widget, add the same OnPreferenceClickListener and add a little code to ensure that only one CheckBox gets clicked.
To start with, here is a sample of a preference XML file.
Okay, so you decide to use the measure() method of the View class in order to get the Adapter item view’s width and height.
In Lollipop devices, it works but when you deploy it some other device or emulator on pre-Lollipop devices, it gives out a NullPointerException when inflating.
This error message is very confusing as it does not pinpoint you to the exact problem in the XML file. The problem though, is not within the XML file layout.
This occurs when your layout is a RelativeLayout and the reason for this is that Inflater does not extract layout_width and layout_height attributes when you do not assign its parent as an argument in the inflate method.
The solution to this problem is to call setLayoutParams() with the specified width and height and then call measure().
That should fix it. Even a width and height of 0 will do the trick.
When Android Lollipop was released, I was excited. Who wouldn’t? Every new version always comes packed with new features and enhancements.
Sad to say when I upgraded to Lollipop it gave my app problems instead. Two things my app used, an XML drawable that displays a radial gradient effect and an animated inside an AsyncTask class that uses Thread.sleep in between.
I had a custom color and named it theme_green. It worked okay in previous versions but in Lollipop 5.0, the radial effect does not work anymore, and so does the color. It seems like only the startColor is used hence the different color result.
The other issue I had was the Thread.sleep inside the doInBackground() where I had a for loop that shows an animated and used the Thread.sleep to simulate a pause in between animation.
The result was that the animated got slow. I had to switch to using a TimerTask instead to preserve the smoothness of the animated that was working prior to Lollipop 5.0.
Oh, and even SystemClock.sleep() inside doInBackground() did not work either.
So there. Just to give you a heads up that you might think it is the Lollipop 5.0 operating system that is the issue. They definitely changed some things that affected how the Thread.sleep() works inside the doInBackground() method of an AsyncTask class.