私はサーブレットからのリクエストとレスポンスに完全に基づいているアンドロイドアプリを開発しています.アラートダイアログのカスタマイズにいくつかのデータを入力しました.2つのことを使用している場合、1つはアラートダイアログのリストからアイテムを削除し、ビューを更新するクロスボタンです.アラート ダイアログ 、2 つ目は、このアラート ダイアログを閉じると想定される閉じるボタンです。アラートダイアログの完全なコーディングを示しています。これらすべてのメソッドで、ボタンのクリック時にアラート ダイアログを呼び出します。
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();
私のために働いていません。よろしくお願いします。