我正在开发一个android应用程序,我已经创建了自定义警报对话框。我声明全局警报对话框和AlertDialog.builder如下。现在我在按钮单击中调用三个方法f1(),f2(),f3()。为什么我的dismiss()方法无法关闭自定义警报对话框
btn_my_order.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
f1();
f2();
f3();
return false;
}
});
,我宣布orderDialog和builde全球范围如下: -
private AlertDialog orderDialog = null;
AlertDialog.Builder builder;
我的F1()框图如下: -
F1{
builder = new AlertDialog.Builder(MainScreen.this);
mContext = getApplicationContext();
/**
* by the help of inflater my ordre is showing in list view
*/
inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
orderDialogLayout = inflater.inflate(R.layout.my_order_list,(ViewGroup)findViewById(R.id.order_list_root));
orderList = (ListView) orderDialogLayout.findViewById(R.id.order_list);
ibOrderDelete = (ImageButton)orderDialogLayout.findViewById(R.id.deleteOrder);
tvPrice = (TextView) orderDialogLayout.findViewById(R.id.order_list_total);
tvTaxes = (TextView) orderDialogLayout.findViewById(R.id.order_list_taxes);
tvTotal = (TextView) orderDialogLayout.findViewById(R.id.order_list_grand_total);
Button bclose = (Button) orderDialogLayout.findViewById(R.id.close);
Button bPlaceOrder = (Button) orderDialogLayout.findViewById(R.id.my_order_placeorder);
bclose.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
orderDialog.dismiss();
System.out.println(" click on close button");
}
});
/**
* click of place order to kitchen
*/
bPlaceOrder.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
System.out.println("Place order click");
palceMyOrdertoServer();
new SendOrderFromTable().execute();
System.out.println("place order to server is called");
String msg = "Your Order is Successfully placed to Kitcken";
Message msgObject = new Message();
msgObject.what = 1;
msgObject.obj = msg;
addMenuItemHandler.sendMessage(msgObject);
orderDialog.dismiss();
}
});}
我的F2()是某些游标工作带数据库
F2{
// many stuff to be here populate data from cursor and bind it with adapter
// no any issue in this mehod
}
Now最后我打电话F3()
F3{
builder.setView(orderDialogLayout);
orderDialog = builder.create();
orderDialog.show();
}
现在我要解释所有我的问题F1()方法用于初始化F2()可以填入数据和F3()来显示自定义警告对话框。为什么我的
orderDialog.dismiss();
不是为me.Even工作虽然我能看到我的logcat有消息
"Click on close button"
这意味着执行是怎么回事解雇()方法,那么为什么自定义警告对话框没”点击关闭。在此先感谢所有
2013-10-27
DJhon
+0
这是因为你在f1中初始化orderDialog时在f3 –
+0
@ Raghunandan ..这意味着如果我在f3()中调用dismiss然后它工作?..并感谢您的快速响应。 –
+0
给它一个试着让我知道 –