自定义对话框未显示视图

时间:2018-04-05 12:32:23

标签: android dialog android-layoutparams

如果出现按钮点击自定义对话框,但是当我认为缺少某些内容时,我做了一个简单的项目? 当我点击按钮但没有显示对话框时出现Toast消息,也没有发生错误,app也没有崩溃。 源代码

<li class="list-group-item">Property damage<div class= "pop"></div></li>
<li class="list-group-item">Bodily injury<div class= "pop"></div></li>

2 个答案:

答案 0 :(得分:1)

您忘了致电 my_dialog.show() 来展示您的my_dialog

private void layout() {
    toast("save");

    LayoutInflater dialoglayout = LayoutInflater.from(EditImageActivity.this);
     View dialogView = dialoglayout.inflate(R.layout.save_image_dialoge,null);

     my_dialog = new Dialog(EditImageActivity.this, R.style.CustomAlertDialog);
     my_dialog.setContentView(dialogView);
     WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
     lp.copyFrom(my_dialog.getWindow().getAttributes());
     lp.width = (int)(getResources().getDisplayMetrics().widthPixels*0.90);
     lp.height = (int)(getResources().getDisplayMetrics().heightPixels*0.90);
     my_dialog.getWindow().setAttributes(lp);
     final Button cancel = dialogView.findViewById(R.id.cancel);
     cancel.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {
             //cancel(true);
             my_dialog.dismiss();
         }
     });
     my_dialog.show();
 }

答案 1 :(得分:0)

也可以调用此方法

   for{
    book <- books
    name <- book.authors
    if name.startsWith("Aavik")
  } yield book.title

你的方法就像这样

books.flatMap(((book) => book.authors.withFilter(((name) => name.startsWith("Aavik"))).map(((name) => book.title))))