我该如何解雇这个AlertDialog?

时间:2014-04-16 12:02:26

标签: android android-alertdialog

我必须使用带有警报对话框数量的搜索栏在购物车中添加产品。我的问题是隐藏这个alertdialog并回到我的原始视图。

任何人都可以帮我解决这个问题吗?

public void onClick(View v) {
             AlertDialog.Builder builder = new AlertDialog.Builder(
                    ProductDetail.this);
            LayoutInflater inflater = ProductDetail.this
                    .getLayoutInflater();
            View v1 = inflater.inflate(R.layout.android_dialog, null);
            builder.setView(v1).setIcon(R.drawable.basket)
                    .setTitle("Add " + Product_name + " to your list");

            SeekBar sbBetVal = (SeekBar) v1.findViewById(R.id.seekBar2);

            tvBetVal = (TextView) v1.findViewById(R.id.total_price);
            Button b1 =(Button)v1.findViewById(R.id.button1);
            Button b2=(Button)v1.findViewById(R.id.button2);
            b2.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {


                }
            });
            b1.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Log.e("Prixtotal",""+v22);
                    new CreateNewProduct().execute();

                }
            });

3 个答案:

答案 0 :(得分:1)

实际上AlertDialog.Builder类没有任何stop()dismiss()方法。

您必须使用AlertDialog类的.create()方法创建AlertDialog.Builder对象。

然后在.Stop()对象上调用.dismiss()AlertDialog

答案 1 :(得分:0)

你必须写

final AlertDialog alertDialog = builder.create();

然后

使用

alertDialog.show();

显示对话框并解除警报使用

alertDialog.dismiss();

答案 2 :(得分:-1)

  

我的问题是隐藏这个警告对话并回到原来的状态   观点。

=>你只需要关闭对话框。它会自动返回到原始视图,这可能是您的产品列表。

你必须创建一个AlertDialog对象,使用它可以随时随地调用dismiss()方法。

AlertDialog dialog = new AlertDialog.Builder(this).create(); 
dialog .dismiss();