Post Top Ad

Post Top Ad

Saturday 29 February 2020

how to design dialog in android





<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@android:color/transparent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">
        <LinearLayout
            android:id="@+id/layout1"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2"></LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:orientation="horizontal"
            android:layout_weight="4">
            <LinearLayout
                android:id="@+id/layout2"
                android:orientation="horizontal"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3.5"></LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:background="@drawable/bg_corner_radius_layout"
                android:layout_weight="20">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="5"></LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:layout_weight="120">
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="15dp"
                        >
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:clickable="false"
                            android:focusable="false"
                            android:fontFamily="@font/source_sans_pro_regular"
                            android:gravity="center"
                            android:text="Warning! "
                            android:textColor="#FF0000"
                            android:textSize="@dimen/text_size_medium_small" />

                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="65">
                        <TextView
                            android:id="@+id/textWarningMsg"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:clickable="false"
                            android:focusable="false"
                            android:fontFamily="@font/source_sans_pro_regular"
                            android:gravity="center"
                            android:text="This order will be canceled and seat will be released."
                            android:textColor="#343434"
                            android:textSize="@dimen/text_size_medium_small" />
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="65">
                        <EditText
                            android:id="@+id/Reason_cancel"
                            android:layout_height="wrap_content"
                            android:hint="Please mention the reason for declining order"
                            android:inputType="textMultiLine"
                            android:lines="5"
                            android:fontFamily="@font/source_sans_pro_regular"
                            android:layout_gravity="center|left"
                            android:gravity="center|left"
                            android:textColor="#343434"
                            android:textSize="@dimen/text_size_medium_small"
                            android:layout_width="fill_parent">
                        </EditText>


                    </LinearLayout>


                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:orientation="horizontal"
                        android:layout_marginBottom="@dimen/fixed_text_size_12"
                        android:layout_marginTop="@dimen/fixed_text_size_12"
                        android:layout_marginLeft="@dimen/bottom_menu_hegiht_width_20"
                        android:layout_marginRight="@dimen/bottom_menu_hegiht_width_20"
                        android:layout_weight="20">
                        <androidx.cardview.widget.CardView
                            android:id="@+id/cancel_button"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:clickable="true"
                            android:focusable="true"
                            android:clipChildren="false"
                            app:cardBackgroundColor="#0000001A"
                            android:layout_marginBottom="2dp"
                            app:cardPreventCornerOverlap="true"
                            app:cardUseCompatPadding="false"
                            android:layout_weight="30">

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:clickable="false"
                                android:focusable="false"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center"
                                android:text="Go back"
                                android:textColor="#E41749"
                                android:textSize="@dimen/text_size_medium_small" />
                        </androidx.cardview.widget.CardView>
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="5"></LinearLayout>
                        <androidx.cardview.widget.CardView
                            android:id="@+id/confirm_button"
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:clickable="true"
                            android:focusable="true"
                            android:clipChildren="false"
                            app:cardCornerRadius="@dimen/text_size_medium"
                            app:cardBackgroundColor="#D20638"
                            android:background="@color/black"
                            android:layout_marginBottom="2dp"
                            app:cardPreventCornerOverlap="true"
                            app:cardUseCompatPadding="false"
                            android:layout_weight="30">

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="#D20638"
                                android:clickable="false"
                                android:focusable="false"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center"
                                android:text="CONFIRM"
                                android:textColor="@color/white"
                                android:textSize="@dimen/text_size_small" />
                        </androidx.cardview.widget.CardView>
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="5"></LinearLayout>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="5"></LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/layout3"
                android:orientation="horizontal"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3.5"></LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:id="@+id/layout4"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2"></LinearLayout>
    </LinearLayout>
</LinearLayout>



Sourse:

private void showCancelOrder() {
    final Dialog OrderQuantityDialog = new Dialog(SeatViewLayout.this, android.R.style.Theme_Black_NoTitleBar);
    OrderQuantityDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    OrderQuantityDialog.setContentView(R.layout.dialog_cancel_layout);
    CardView cancel_button = (CardView)OrderQuantityDialog.findViewById(R.id.cancel_button);
    CardView confirm_button = (CardView)OrderQuantityDialog.findViewById(R.id.confirm_button);
    final EditText Reason_cancel = (EditText) OrderQuantityDialog.findViewById(R.id.Reason_cancel);
//    final String CancelMessage = Reason_cancel.getText().toString().trim();    confirm_button.setOnClickListener(new View.OnClickListener() {
        @Override        public void onClick(View view) {

            String CancelMessage = Reason_cancel.getText().toString();
            if(DashBoard.socketIoClass.client.connected())
            {
                try {
                    JSONObject object = new JSONObject();
                    object.put("type", "cancel_order");
                    JSONObject messgae = new JSONObject();
                    messgae.put("SocketId", DashBoard.socketIoClass.mySocketId);
                    messgae.put("restaurant_id", DashBoard.restaurant_id);
                    messgae.put("order_no",orderNo);
                    messgae.put("user_id", DashBoard.user_id);
                    messgae.put("message",CancelMessage);
                    object.put("message", messgae);
                    DashBoard.socketIoClass.sendMessage(object);

                    Toast.makeText(SeatViewLayout.this, "Cancel Order", Toast.LENGTH_LONG).show();

                /*    orderHistoryListAdapter.notifyDataSetChanged();                    if (DineInFragment.dineHandler != null) {                        DineInFragment.dineHandler.sendEmptyMessage(DineInFragment.DineHandler.Upate_UI);                    }*/                    OrderQuantityDialog.dismiss();
                    finish();

                }
                catch (Exception ex)
                {

                }


          }



        }
    });
    cancel_button.setOnClickListener(new View.OnClickListener() {
        @Override        public void onClick(View view) {
            OrderQuantityDialog.dismiss();
        }
    });
    OrderQuantityDialog.setCancelable(false);
    OrderQuantityDialog.show();
}

No comments:

Post a Comment