Question

I am developing a android App which is totally based on request and response from servlet.I have populate some data in customize Alert-dialog Where i using two thing one is cross button that will delete item from list in alert-dialog and update view of alert dialog , second thing is close button that will suppose to dismiss this alert-dialog. I am showing full coding of my alert-dialog. I calling alert dialog on button click by all these method.

 intiliazeOrderListDialog();
 showOrderListDialog();

My decleration is as follow

public AlertDialog detailsDialog, orderDialog;
AlertDialog.Builder builder;

Now i am going to post my intiliazeOrderListDialog() block.

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

        }
    }); 
}

and at last i am going to post showOrderListDialog(); block

  public void showOrderListDialog() {  
    builder.setView(orderDialogLayout);
    orderDialog = builder.create();
    orderDialog.show();
}

I know i have posted too many codes but its conveniences for those who want to help me . I have a very simple problem why my

            orderDialog.dismiss();

is not working for me.? Thanks in advance to all .

Was it helpful?

Solution

Finally i solve my own issue . "Self help is best help ;;".

It was issue of calling method in setOnClickListener.

I just call it,

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

    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top