2016-07-04 18 views
0
view.findViewById(R.id.doc_prof_det_add_speciality_btn).setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       AlertDialog.Builder alertDialog = new AlertDialog.Builder(v.getContext()); 
       LayoutInflater factory = LayoutInflater.from(v.getContext()); 
       final View view = factory.inflate(R.layout.doc_prof_det_add_speciality, null); 
       alertDialog.setView(view); 

      alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        dialog.dismiss(); 
       } 
      }); 

      alertDialog.setPositiveButton("Save", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 

       } 
      }); 

      alertDialog.show(); 
     } 
    }); 
+0

请使用正确的代码格式化。 – karan

+0

可能的[如何设置对话框以全屏显示?]的副本(http://stackoverflow.com/questions/6329360/how-to-set-dialog-to-show-with-full-screen) –

回答

1

试试这个:

alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        dialog.dismiss(); 
       } 
      }); 

      alertDialog.setPositiveButton("Save", new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 

       } 
      }); 

      alertDialog.show(); 


      //Grab the window of the dialog, and change the width 
      WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); 
      Window window = alertDialog.getWindow(); 
      lp.copyFrom(window.getAttributes()); 
      //This makes the dialog take up the full width 
      lp.width = WindowManager.LayoutParams.MATCH_PARENT; 
      lp.height = WindowManager.LayoutParams.WRAP_CONTENT; 
      window.setAttributes(lp); 

    } 
}); 
+0

hello i添加下面的代码,但它会给错误:(60,44)错误:无法找到符号方法getWindow() –

+0

检查了这一点:http://www.techrepublic.com/article/pro-tip-unravel-the-mystery-的-机器人 - 全屏对话片段/ –

相关问题