我正在开发一个完全基于来自 servlet 的请求和响应的 android 应用程序。我在自定义警报对话框中填充了一些数据,其中我使用两件事一是交叉按钮,它将从警报对话框中的列表中删除项目并更新视图警报对话框,第二件事是关闭按钮,它将假设关闭此警报对话框。我正在显示我的警报对话框的完整编码。我通过所有这些方法在按钮单击时调用警报对话框。
intiliazeOrderListDialog();
showOrderListDialog();
我的声明如下
public AlertDialog detailsDialog, orderDialog;
AlertDialog.Builder builder;
现在我要发布我的 intilizeOrderListDialog() 块。
public void intiliazeOrderListDialog() {
builder = new AlertDialog.Builder(MainScreen.this);
mContext = getApplicationContext();
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 closowse");
}
});
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();
}
});
}
最后我要发布 showOrderListDialog(); 堵塞
public void showOrderListDialog() {
builder.setView(orderDialogLayout);
orderDialog = builder.create();
orderDialog.show();
}
我知道我发布了太多代码,但它对那些想要帮助我的人来说很方便。我有一个非常简单的问题,为什么我的
orderDialog.dismiss();
不适合我。?在此先感谢大家。