1 /**2 * 3 * Event Monitoring4 */5 @Override6 Public voidOnClick (View v) {7 Switch(V.getid ()) {8 CaseR.id.item_back:9 finish ();Ten overridependingtransition (R.anim.lefttoright, r.anim.righttoleft); One Break; A Caser.id.item_textsize: - Showcchoosedig (); - the default: - Break; - } - + } - + /** A * at * Show dialog box - */ - - Private intMcurrentchooseitem;//record the currently selected item - Private intmcurrentitem=2;//record the font that is changed after the current selection is determined - PrivateString URL; in - Private voidShowcchoosedig () { toAlertdialog.builder Builder =NewAlertdialog.builder ( This);//Create dialog box + -String[] Items=Newstring[]{"Super Size Font", "Large font", "Normal font", "Small Font", "Super small Font"}; the *Builder.settitle ("Font settings"); $Builder.setsinglechoiceitems (items, Mcurrentitem,NewDialoginterfacePanax Notoginseng . Onclicklistener () { - the @Override + Public voidOnClick (Dialoginterface Dialog,intwhich) { ASystem.out.println ("Checked:" +which); themcurrentchooseitem=which; + - } $ }); $ - /** - * Set the OK button to listen the */ - WuyiBuilder.setpositivebutton ("OK",NewOnclicklistener () { the - @Override Wu Public voidOnClick (Dialoginterface Dialog,intwhich) { -WebSettings settings = Item_webnews.getsettings ();//Create an Websetting object About Switch(mcurrentchooseitem) { $ Case0: - settings.settextsize (Textsize.larger); - Break; - Case1: A settings.settextsize (textsize.largest); + Break; the Case2: - settings.settextsize (textsize.normal); $ Break; the Case3: the settings.settextsize (textsize.smaller); the Break; the Case4: - settings.settextsize (textsize.smallest); in Break; the the default: About Break; the } theMcurrentitem=mcurrentchooseitem;//after clicking, the font becomes the selected font size the + } - the Bayi }); the the /** - * Set Cancel button - */ theBuilder.setnegativebutton ("Cancel",NULL);//no need to set up monitoring because the default click is canceled the theBuilder.show ();//Show the dialog box the - the}
dialog box for setting font size