1

私はサーブレットからのリクエストとレスポンスに完全に基づいているアンドロイドアプリを開発しています.アラートダイアログのカスタマイズにいくつかのデータを入力しました.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();

私のために働いていません。よろしくお願いします。

4

1 に答える 1

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));

    }
于 2013-10-31T06:41:14.490 に答える