我正在开发一个完全基于来自servlet的请求和响应的Android应用程序。我已经在自定义警报对话框中填充了一些数据我在哪里使用两个是交叉按钮,它将从警告对话框中的列表中删除项目更新警报对话框的视图,第二件事是关闭按钮,它将假设关闭此警报对话框。我正在显示我的警报对话框的完整编码。我通过所有这些方法点击按钮来调用警报对话框。
intiliazeOrderListDialog();
showOrderListDialog();
我的声明如下
public AlertDialog detailsDialog, orderDialog;
AlertDialog.Builder builder;
现在我要发布我的intiliazeOrderListDialog()块。
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();
不适合我。?在此先感谢所有人。
答案 0 :(得分:1)
最后我解决了自己的问题。 “自助是最好的帮助;;”。
这是setOnClickListener中调用方法的问题。
我只是称呼它,
android:clickable="true"
android:onClick="clickHandler"
if (v.getId() == R.id.myOrder) {
System.out.println("Click my Order");
System.out.println("OrderListAdapter.totalCount ="
+ OrderListAdapter.totalCount);
// select COUNT(*) from CDs;
int jcount = 0;
jcount = countjournals();
System.out.println("jcount = " + jcount);
// Count implementation at my Order
if (jcount < 1) {
alertShow();
} else {
intiliazeOrderListDialog();
showOrderListDialog();
}
// startActivity(new Intent(RestaurantHome.this,
// MyOrderList.class));
}