The example in this article describes how Android sets the preferencecategory background color. Share to everyone for your reference. The specific analysis is as follows:
You may encounter, preferencecategory default is a black background, how we replaced the preferencescreen background, then this separator looks very ugly, then how to change the background? We can do this by customizing the view.
The code is as follows:
The public class Mypreferencecategory extends Preferencecategory {public
mypreferencecategory AttributeSet attrs) {
Super (context, attrs);
}
@Override
protected void Onbindview (view view) {
Super.onbindview (view);
View.setbackgroundcolor (Color.parsecolor ("#b0000000"));
if (view instanceof TextView) {
TextView TV = (TextView) view;
Tv.settextsize ();
Tv.settextcolor (Color.Black);}}
When the XML is invoked (custom usage ...). You know):
<com.blogchen.myview.mypreferencecategory android:title= "Other" >
<preferencescreen
android:key= " Blog_ "
android:summary=" author blog address "
android:title=" visit blog ">
<intent
android:action=" Android.intent.action.VIEW "
android:data=" http://www.jb51.net "/>
</PreferenceScreen>
< /com.blogchen.myview.mypreferencecategory>
I hope this article will help you with your Android program.