Write inside your activity: @Override public void handleOnLongClick(View v, int elementActionCode) { if (ORDER_SUMMARY_POPUP == elementActionCode) { View orderSummaryLayout = _initiatePopupWindow(); if(orderSummaryLayout != null) _setOrderSummaryValues(orderSummaryLayout); } private View _initiatePopupWindow() { int xCoOrdinate = 25; int yCoOrdinate = 25; int xWindowPerc = 10; int yWindowPerc = 50; Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); View layout = null; xCoOrdinate = ((width*xWindowPerc)/100); yCoOrdinate = ((height*yWindowPerc)/100); width = width - xCoOrdinate; height = height - yCoOrdinate; try { // We need to get the instance of the LayoutInflater LayoutInflater inflater = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); layout = inflater.inflate(R.layout.order_summary_popup, (ViewGroup) findViewById(R.id.orderPopupWindow)); popupWindow = new PopupWindow(layout, width, height, true); popupWindow.showAtLocation(layout, Gravity.AXIS_X_SHIFT, (xCoOrdinate/2), (yCoOrdinate/2)); } catch (Exception ex) { Log.e(TAG, "Error while initiation of the Order Summary Popup." + ex.getMessage()); } return layout; } private void _setOrderSummaryValues(View layout) { try { ImageView btnClosePopup = (ImageView) layout.findViewById(R.id.btn_close_popup1); btnClosePopup.setOnClickListener(new UUIHandlers.UListener(this,ORDER_SUMMARY_POPUP_CLOSE)); TextView totGrossAmt = (TextView) layout.findViewById(R.id.totalGrossAmt1); totGrossAmt.setText(String.valueOf(df.format(totalGrossAmount))); totGrossAmt.setText(CommonUtils.getSystemCurrency(this, totGrossAmt, true)); TextView totDiscAmt = (TextView) layout.findViewById(R.id.totalDiscAmt1); totDiscAmt.setText(String.valueOf(df.format(totalDiscAmount))); totDiscAmt.setText(CommonUtils.getSystemCurrency(this, totDiscAmt, true)); TextView totTaxableAmt = (TextView) layout.findViewById(R.id.totalTaxableAmt1); totTaxableAmt.setText(String.valueOf(df.format(totalTaxableAmount))); totTaxableAmt.setText(CommonUtils.getSystemCurrency(this, totTaxableAmt, true)); TextView totTaxAmt = (TextView) layout.findViewById(R.id.totalTaxAmt1); totTaxAmt.setText(String.valueOf(df.format(totalTaxAmount))); totTaxAmt.setText(CommonUtils.getSystemCurrency(this, totTaxAmt, true)); TextView totBilAmt = (TextView) layout.findViewById(R.id.totalOrderAmount); totBilAmt.setText(String.valueOf(df.format(totalOrderAmount))); totBilAmt.setText(CommonUtils.getSystemCurrency(this, totBilAmt, true)); TableLayout orderSummaryTable = (TableLayout) layout .findViewById(R.id.orderSummaryPopupTable); } catch (Exception e) { Log.e(TAG, "Error while setting Bill Summary Popup values. " + e.getMessage()); } } Pop up xml file: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/orderPopupWindow" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="3dp" android:background="@drawable/popup_window_background" android:gravity="top" android:orientation="vertical" android:weightSum="100" > <TableLayout android:id="@+id/orderSummaryTable" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:gravity="top" android:orientation="vertical" > <TableRow android:id="@+id/discAmtRow" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="3dp" android:layout_marginTop="5dp" > <TextView android:id="@+id/txtView" style="@style/textview_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight=".99" android:gravity="center" android:text="@string/order_popup_header" android:textStyle="bold" /> <ImageView android:id="@+id/btn_close_popup1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_weight=".01" android:src="@drawable/popup_cancel" /> </TableRow> <View android:id="@+id/sku_search_bottom_seperator" style="@style/seperator_style" android:layout_height="1dp" android:layout_marginBottom="3dp" android:layout_marginTop="3dp" /> </TableLayout> <ScrollView android:id="@+id/orderScrollView" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TableLayout android:id="@+id/orderSummaryPopupTable" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="2dp" android:orientation="vertical" android:weightSum="100"> <TableRow android:id="@+id/orderSummaryPopupRow2" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="@string/gross_amt_label2" android:textColor="@color/highlight_text_color" /> <TextView android:id="@+id/totalGrossAmt1" style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:layout_marginRight="1dp" android:gravity="right" android:text="@string/initial_gross_amt" /> </TableRow> <TableRow android:id="@+id/orderSummaryPopupRow" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="@string/disc_amt_label" android:textColor="@color/highlight_text_color" /> <TextView android:id="@+id/totalDiscAmt1" style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:layout_marginRight="1dp" android:gravity="right" android:text="@string/initial_gross_amt" /> </TableRow> <TableRow android:id="@+id/orderSummaryPopupRow3" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="@string/taxable_amt_label" android:textColor="@color/highlight_text_color" /> <TextView android:id="@+id/totalTaxableAmt1" style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:layout_marginRight="1dp" android:gravity="right" android:text="@string/initial_gross_amt" /> </TableRow> <TableRow android:id="@+id/orderSummaryPopupRow4" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="@string/total_tax_amt_label" android:textColor="@color/highlight_text_color" /> <TextView android:id="@+id/totalTaxAmt1" style="@style/textview_style" android:layout_height="wrap_content" android:layout_weight="0.5" android:layout_marginRight="1dp" android:gravity="right" android:text="@string/initial_gross_amt" /> </TableRow> </TableLayout> </ScrollView> <TableLayout android:id="@+id/orderSummaryNetAmt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:gravity="bottom" android:orientation="vertical" > <View android:id="@+id/sku_search_bottom_seperator" style="@style/seperator_style" android:layout_height="1dp" android:layout_marginBottom="3dp" android:layout_marginTop="3dp" /> <TableRow android:id="@+id/totalOrderAmountRow" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="2dp" > <TextView android:id="@+id/totalOrderAmountText" style="@style/textview_style" android:layout_height="wrap_content" android:layout_marginLeft="1dp" android:layout_weight="1" android:text="@string/total_order_amt_label" android:textColor="@color/highlight_text_color" android:textStyle="bold" /> <TextView android:id="@+id/totalOrderAmount" style="@style/textview_style" android:layout_height="wrap_content" android:layout_marginRight="1dp" android:layout_weight="1" android:gravity="right" android:text="@string/initial_gross_amt" android:textStyle="bold" /> </TableRow> <View android:id="@+id/sku_search_bottom_seperator" style="@style/seperator_style" android:layout_height="1dp" android:layout_marginBottom="3dp" android:layout_marginTop="3dp" /> </TableLayout> </LinearLayout>
source share