Pages

Friday, 13 September 2013

Android custom alert dialog and To fill the device width


final Dialog  dialog=new Dialog(AgendaDetails.this);
         dialog.setTitle("Set reminder");
         dialog.setContentView(R.layout.alertdialoglist);
                        
         ListView listView = (ListView) dialog.findViewById(R.id.listView1);
         listView.setAdapter(new ReminderViewadapter(AgendaDetails.this));
                  

// here we need to set the layout parameter to the alert dialogue.

         WindowManager.LayoutParams lp = new        WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.show();
            dialog.getWindow().setAttributes(lp);

1 comment: