Mainactivity as follows:
Package C.c.testdialog;import Android.app.activity;import Android.app.alertdialog;import Android.app.alertdialog.builder;import Android.app.dialog;import Android.content.dialoginterface;import Android.os.bundle;import Android.view.contextthemewrapper;import Android.view.view;import Android.view.view.onclicklistener;import android.widget.button;/** * Demo Description: * Change the font size in the System dialog box * Method: * 0 Set the parent of a style to @android:style/theme.dialog * Modify <item name= "Android:textsize" >30sp</item> * This approach is similar to subclasses overriding the parent class method * 1 Using the context and the style to generate Contextthemewrapper * 2 using the Contextthemewrapper Production Builder Object */public class Mainactivity extends Activity {private Button Mbutton; @Overrideprotected void OnCreate (Bundle savedinstancestate) {Supe R.oncreate (savedinstancestate); Setcontentview (R.layout.main); init ();} private void Init () {mbutton= (Button) Findviewbyid (R.id.button); Mbutton.setonclicklistener (new Clicklistenerimpl ()) ;} Private class Clicklistenerimpl implements Onclicklistener {@Overridepublic void ONclick (View v) {switch (V.getid ()) {Case r.id.button://the Customize dialog Box ShowDialog (); break;default:break;}}} private void ShowDialog () {Dialog Dialog = null; Contextthemewrapper contextthemewrapper = new Contextthemewrapper (mainactivity.this, R.style.dialog); Builder builder = new Alertdialog.builder (contextthemewrapper); Builder.setitems (r.array.share_array,new Dialoginterface.onclicklistener () {@Overridepublic void OnClick (dialoginterface dialog, int which) {switch (which) { Case 0:SYSTEM.OUT.PRINTLN ("-----> Send mail") break;case 1:system.out.println ("-----> Share to Facebook") Break;case 2: SYSTEM.OUT.PRINTLN ("-----> Share to Twitter"); break;default:break;}}); Dialog = Builder.create ();d ialog.show ();}}
Arrays.xml as follows:
<?xml version= "1.0" encoding= "Utf-8"?><resources> <string-array name= "Share_array" > <item> Send mail </item> <item> share to facebook</item> <item> share to Twitter</item> </string-array></resources>
Styles.xml as follows:
<resources> <style name= "Appbasetheme" parent= "Android:Theme.Light" ></style> <style Name= "Apptheme" parent= "Appbasetheme" ></style> <style name= "dialog" parent= "@android: style/ Theme.dialog "> <item name=" android:textsize ">30sp</item> </style></resources >