-1

カスタマイズアラートダイアログを作成したAndroidアプリを開発しています。Globally アラート ダイアログと AlertDialog.builder を次のように宣言します。今、ボタンクリックで 3 つのメソッド f1()、f2()、f3() を呼び出しています。

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
     }

最後に f3() を呼び出しています

      F3{
        builder.setView(orderDialogLayout);
    orderDialog = builder.create();
    orderDialog.show();
       }

ここで、すべての問題を説明します f1() メソッドは初期化用です f2() はデータの入力用であり、 f3() はカスタマイズアラートダイアログを表示するためのものです なぜ私の

       orderDialog.dismiss();

私のlogcatにメッセージが表示されているにもかかわらず、機能していません

        "Click on close button"

これは、実行がdismiss()メソッドで行われていることを意味し、クリック時にカスタマイズアラートダイアログが閉じなかった理由です。すべてに前もって感謝します

4

1 に答える 1