如果条件,对话不会解雇

时间:2015-12-10 08:33:28

标签: java android progressdialog

我试图在if条件为true的情况下解除对话但是没有工作。 在if条件中输入的对话框但不是dismiss.in如果条件Toast消息显示正确。

public void showIncomingCall() {

        int getTotal = 0;

        if(showincoming != null && showincoming.isShowing() )
        {
            //adapter1.notifyDataSetChanged();
            //showincoming.dismiss();
            return;
        }
        else {
            showincoming = new Dialog(MainActivity.this);
            showincoming.requestWindowFeature(Window.FEATURE_NO_TITLE);
            showincoming.setContentView(R.layout.custome_dialog);
            listdialog = (ListView) showincoming.findViewById(R.id.incoming_list);
            //adapter1 = new CustomeListAdapter(MainActivity.this);
            listdialog.setAdapter(adapter1);
            //adapter1.notifyDataSetChanged();
             close = (ImageButton) showincoming.findViewById(R.id.dialog_close);

            close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    showincoming.dismiss();
                    adapter1.notifyDataSetChanged();
                }
            });

            adapter1.notifyDataSetChanged();

            for (int i = 0; i < listdialog.getCount(); i++) {
                parentView = getViewByPosition(i, listdialog);
                String getString = ((TextView) parentView.findViewById(R.id.tvLineStatus)).getText().toString();

                if (getString.toString().equals("Idle") || getString.toString().equals("Disconnect") || getString.toString().equals("Dialing")) {
                    getTotal += 1;
                }
            }
            if (getTotal >= 7) {
                    showincoming.dismiss();
                    Toast.makeText(getApplicationContext(),"getTotal" + getTotal,Toast.LENGTH_LONG).show();
                    adapter1.notifyDataSetChanged();

                //adapter1.setNotifyOnChange(true);
            }
            //Toast.makeText(MainActivity.this,getTotal+"getTotal",Toast.LENGTH_LONG).show();
            adapter1.notifyDataSetChanged();
            listdialog.invalidateViews();
            if(!showincoming.isShowing()) {
                showincoming.show();
            }
        }
}

1 个答案:

答案 0 :(得分:0)

var x = Input.gyro.rotationRate.x; var y = Input.gyro.rotationRate.y; var z = Input.gyro.rotationRate.z; transform.eulerAngles = new Vector3 (x, y, z); showincoming = new Dialog(MainActivity.this);下面声明  即在int getTotal = 0;声明之外 然后你可以获得对话框对象的referance并可以忽略对话框。试试看,让我知道