android - How to make dialog to look like ICS theme -


from service i'm creating dialog via dummy activity. here i'm able see black background, overall theme of dialog looks android v 2.2. application minimum api level 8, if use holo theme says need min api level 14.

here code used create dialog. how ics theme dialog.

  public class previewdialog extends activity{      @override     public void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);          // show popup dialog         showdialog(0);       }    @override protected dialog oncreatedialog(int id) {     super.oncreatedialog(id);      // build dialog     alertdialog.builder alert = new alertdialog.builder(this);      alert.settitle("alarm reminder");     alert.setmessage("its time alarm ");     alert.setcancelable(false);      alert.setpositivebutton("dismiss", new dialoginterface.onclicklistener() {         public void onclick(dialoginterface dialog, int whichbutton) {             googletaskpreviewdialog.this.finish();         }     });      // create , return dialog     alertdialog dlg = alert.create();      return dlg; } } 

my manifest file entry

 <activity android:name="previewdialog" android:theme="@android:style/theme.translucent.notitlebar"></activity>  

you can not use theme holo design api >= 14/ice cream sandwich

solution:

you can either design own dialog layout dialog holo theme or check if current device's api greater or equal ice cream sandwich , set holo theme dialog if else use dialog theme 2.2.

sample:

        alertdialog.builder alert;         // build dialog         if(android.os.build.version.sdk_int >= android.os.build.version_codes.ice_cream_sandwich)             alert = new alertdialog.builder(this,android.r.style.theme_holo_dialog);         else             alert = new alertdialog.builder(this); 

also take note oncreatedialog deprecated, recommend using instance object of alertdialog showing dialog instead of creating inside oncreatedialog , showing calling showdialog.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -