如果在弹出窗口中打开列表视图,如何打开列表项上的上下文菜单

时间:2012-06-22 08:18:49

标签: android

 LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.shopping_list_layout, null);

            Button cancel_btn = (Button) layout.findViewById(R.id.cancel_btn);
            Button clear_list_btn = (Button) layout.findViewById(R.id.clear_list);
            Button remind_me_btn = (Button) layout.findViewById(R.id.calender_btn);
            Button sent_mail_btn = (Button) layout.findViewById(R.id.mail_btn);
            Button all_addto_cart_btn = (Button) layout
                    .findViewById(R.id.add_to_cart);

            TextView oderable_no_of_products = (TextView) layout
                    .findViewById(R.id.orderable_product_no);
            TextView oderable_products_price = (TextView) layout
                    .findViewById(R.id.oderable_product_price);

            final TextView no_of_product = (TextView) layout
                    .findViewById(R.id.no_of_product_inshopping_list);
            final TextView total_price_in_shopinglist = (TextView) layout
                    .findViewById(R.id.total_sum);

            final ListView shopping_listview = (ListView) layout
                    .findViewById(R.id.shopping_listview);

            final PopupWindow pw = new PopupWindow(layout, 1105, 717, true);
            pw.showAtLocation(layout, Gravity.CENTER, 0, 0);

            LoadProductsForShoppingList shopping_list_obj = new LoadProductsForShoppingList(
                    DynamicTableActivity.this, pw, ac.getImageloder(),
                    shopping_listview, no_of_product, total_price_in_shopinglist,
                    oderable_no_of_products, oderable_products_price);
            shopping_list_obj.execute(Constant.shopping_list_query);

            cancel_btn.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    pw.dismiss();
                }

            });

            all_addto_cart_btn.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    // add all products list to cart
                    addAllProductsToCartFromShoppingList();
                }

            });

            clear_list_btn.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    // clear shopping list
                    clearShoopingList(shopping_listview, no_of_product,
                            total_price_in_shopinglist);
                }

            });

`如果列表视图在弹出窗口中打开,如何打开列表项上的上下文菜单。

1 个答案:

答案 0 :(得分:1)

你可以使用

shopping_listview.setOnItemLongClickListener(new OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view,
                    int position, long id) {
长按

显示带有列表的对话框.....