Example usage for android.widget PopupWindow PopupWindow

List of usage examples for android.widget PopupWindow PopupWindow

Introduction

In this page you can find the example usage for android.widget PopupWindow PopupWindow.

Prototype

public PopupWindow(View contentView, int width, int height, boolean focusable) 

Source Link

Document

Create a new popup window which can display the contentView.

Usage

From source file:net.quduo.pixel.interfaces.android.fragment.ContactFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_contact, container, false);

    // TODO ContextMenu
    final ArrayList<HashMap<String, Object>> mPopupWindowListItem = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> map1 = new HashMap<String, Object>();
    // map1.put("item_image", R.drawable.icon_message);
    map1.put("item_icon", R.string.icon_chat_add_group);
    // map1.put("item_text", "" + i + "");
    map1.put("item_title", "??");
    mPopupWindowListItem.add(map1);/*  w w  w  . jav a 2 s  .co  m*/
    HashMap<String, Object> map2 = new HashMap<String, Object>();
    // map2.put("item_image", R.drawable.icon_message);
    map2.put("item_icon", R.string.icon_chat_add_group);
    // map2.put("item_text", "" + i + "");
    map2.put("item_title", "");
    mPopupWindowListItem.add(map2);

    // Set the adapter
    mContactListAdapter = new ContactListAdapter(this.getActivity(), mSourceDataList);
    mListView = (ListView) view.findViewById(R.id.contact_list_view);
    mListView.setAdapter(mContactListAdapter);

    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (null != mListener) {
                // Notify the active callbacks interface (the activity, if the
                // fragment is attached to one) that an item has been selected.
                // mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id);
            }
        }
    });
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) {
            // Log.e(TAG, DummyContent.ITEMS.get(i).content);
            Log.e(TAG, mSourceDataList.get(i).getContactName());

            // ??
            View contextMenuView = inflater.inflate(R.layout.layout_common_context_menu, null);
            // PopupWindow
            final PopupWindow popupWindow = new PopupWindow(contextMenuView,
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, false);
            // ???
            // new ColorDrawable(0) getResources().getDrawable(R.drawable.popup_window_background)
            popupWindow.setBackgroundDrawable(new ColorDrawable(0x90000000));
            // ??
            // popupWindow.setOutsideTouchable(true);
            // ??
            popupWindow.setFocusable(true);
            // ?
            // popupWindow.setAnimationStyle(R.style.PopupAnimation);
            // ?
            // popupWindow.setOnDismissListenerd(new PopupWindow.OnDismissListener(){});
            /*
            // PopupWindow,PopupWindow
            popupWindow.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    popupWindow.dismiss();
                    return true;
                }
                return false;
            }
            });
            */
            popupWindow.getContentView().setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    popupWindow.dismiss();
                }
            });
            if (popupWindow.isShowing()) {
                // ???????????
                popupWindow.dismiss();
            } else {
                // SimpleAdapter mSimpleAdapter = new SimpleAdapter(getApplicationContext(), mPopupWindowListItem, R.layout.main_popup_menu_item, new String[]{"item_icon", "item_title"}, new int[]{R.id.popup_menu_item_icon, R.id.popup_menu_item_title});

                BaseAdapter mSimpleAdapter = new BaseAdapter() {

                    @Override
                    public int getCount() {
                        return mPopupWindowListItem.size();
                    }

                    @Override
                    public Object getItem(int i) {
                        return null;
                    }

                    @Override
                    public long getItemId(int i) {
                        return 0;
                    }

                    @Override
                    public View getView(int position, View convertView, ViewGroup parent) {

                        if (convertView == null) {
                            LayoutInflater inflater = LayoutInflater.from(getActivity());
                            convertView = inflater.inflate(R.layout.list_item_common_context_menu, parent,
                                    false);
                        }
                        // TextView popupMenuItemIcon = (TextView) convertView.findViewById(R.id.popup_menu_item_icon);
                        // if (DEBUG) Log.d(TAG, "item_icon:" + mPopupWindowListItem.get(position).get("item_icon"));
                        // popupMenuItemIcon.setTypeface(typeface);
                        // if (popupMenuItemIcon.getTypeface() != typeface) {
                        //    popupMenuItemIcon.setTypeface(typeface);
                        // }
                        // popupMenuItemIcon.setText(Integer.valueOf(mPopupWindowListItem.get(position).get("item_icon").toString()));

                        TextView popupMenuItemTitle = (TextView) convertView
                                .findViewById(R.id.context_menu_action_text_view);
                        popupMenuItemTitle
                                .setText(mPopupWindowListItem.get(position).get("item_title").toString());

                        return convertView;
                    }
                };

                TextView contextMenuTitle = (TextView) contextMenuView.findViewById(R.id.context_menu_title);
                contextMenuTitle.setText(mSourceDataList.get(i).getContactName());

                ListView mPopupMenuListView = (ListView) contextMenuView
                        .findViewById(R.id.context_menu_list_view);
                mPopupMenuListView.setAdapter(mSimpleAdapter);

                // ?
                // PopupWindow??View?x,y?????
                // popupWindow.showAsDropDown(v, -460, 0);
                // ?View?,?parent????-90
                // Gravity.TOP|Gravity.LEFT, 0, 150
                popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
                popupWindow.update();
            }

            return true;
        }
    });

    mLetterQueryView = (LetterQueryView) view.findViewById(R.id.letter_query_view);
    mLetterTextDialog = (TextView) view.findViewById(R.id.letter_text_dialog);
    mLetterQueryView.setTextView(mLetterTextDialog);

    // ??
    mLetterQueryView.setOnTouchingLetterChangedListener(new LetterQueryView.OnTouchingLetterChangedListener() {

        @Override
        public void onTouchingLetterChanged(String s) {
            // ??
            int position = mContactListAdapter.getPositionForSection(s.charAt(0));
            if (position != -1) {
                mListView.setSelection(position);
            }

        }
    });

    return view;
}

From source file:com.zhenlaidian.ui.InputCarNumberActivity.java

private void initPopWindow(final ArrayList<CarTypeItem> car_type) {

    View cartypeView = getLayoutInflater().inflate(R.layout.cartype_layout, null, false);
    pow = new PopupWindow(cartypeView, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT, true);
    // ??BackPopupWindow
    pow.setOutsideTouchable(true);/*from ww  w . j a v a  2  s.  c o  m*/
    pow.setBackgroundDrawable(new BitmapDrawable());
    cartypeView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (pow != null && pow.isShowing()) {
                pow.dismiss();
                pow = null;
            }
            return false;
        }
    });
    pow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Drawable d = getResources().getDrawable(R.drawable.set_collect_on);
            d.setBounds(0, 0, d.getMinimumWidth(), d.getMinimumHeight()); //
            cartype.setCompoundDrawables(null, null, d, null);
        }
    });
    listtype = ((ListView) cartypeView.findViewById(R.id.cartype_lv_popview));

    if (car_type.size() > 9) {
        ViewGroup.LayoutParams params = listtype.getLayoutParams();
        params.height = CommontUtils.getScreenWidth(this);
        listtype.setLayoutParams(params);
    }
    cartypeAdapter = new CartypeAdapter(car_type, context);
    listtype.setAdapter(cartypeAdapter);
    listtype.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            cartypecode = car_type.get(position).getId();
            cartype.setText(car_type.get(position).getName());
            pow.dismiss();
        }
    });
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
 * Afficher une boite au milieu de la carte si aucun utilisateur est connects
 * pour proposer a l'invit, de se connecter ou s'incrire aupres du service LTP.
 *///from  w  ww  . ja  va2 s .c om
public final void popupGuest() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;
    //final int height = dm.heightPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupGuest);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_guest, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupGuest = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupGuest.setBackgroundDrawable(new BitmapDrawable());
    popupGuest.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupGuest.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton des paramtres
    Button btLogin = (Button) layout.findViewById(R.id.btnPopupLogin);
    btLogin.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // La constante CODE_MON_ACTIVITE reprsente lidentifiant de la requte
            // (requestCode) qui sera utilis plus tard pour identifier lactivit
            // renvoyant la valeur de retour.
            Intent i = new Intent(activity, LoginActivity.class);
            activity.startActivityForResult(i, 1);

            popupGuest.dismiss();
        }
    });

    // Ecouteur d'vnement sur le bouton des paramtres
    Button btSignup = (Button) layout.findViewById(R.id.btnPopupSignup);
    btSignup.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // La constante CODE_MON_ACTIVITE reprsente lidentifiant de la requte
            // (requestCode) qui sera utilis plus tard pour identifier lactivit
            // renvoyant la valeur de retour.
            Intent i = new Intent(activity, SignupActivity.class);
            activity.startActivityForResult(i, 3);

            popupGuest.dismiss();
        }
    });

    // Ecouteur d'vnement sur le bouton pour fermer l'application
    Button close = (Button) layout.findViewById(R.id.btnPopupClose);
    close.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            popupGuest.dismiss();
        }
    });
}

From source file:com.insthub.O2OMobile.Activity.C17_ApplyFormActivity.java

/**
 * popwindow/*from   w w w.  j a  v  a2s .  c o  m*/
 *
 * @param parent
 */
private void showPopWindow(View parent) {
    int id = parent.getId();
    switch (id) {
    case R.id.service_type:
        if (mServiceListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mServicePopwindowView = layoutInflater.inflate(R.layout.service_type_popwindow, null);
            mServicePopwindowListView = (ListView) mServicePopwindowView
                    .findViewById(R.id.service_type_pop_listview);
            mServiceListPopwindow = new PopupWindow(mServicePopwindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mServiceTypePopAdapter == null) {
            mServiceTypePopAdapter = new ServiceTypePopAdapter(this, mServiceModel.publicServiceTypeList);
            mServicePopwindowListView.setAdapter(mServiceTypePopAdapter);
        }
        mServiceListPopwindow.setFocusable(true);
        // ?
        mServiceListPopwindow.setOutsideTouchable(true);
        mServiceTypeArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mServiceListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mServiceListPopwindow.showAsDropDown(parent);
        mServiceListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mServiceTypeArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mServicePopwindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_TYPE serviceType = mServiceTypeList.get(position);
                mServiceTypeId = serviceType.id;
                mServiceTypeTitle.setText(serviceType.title);
                mServiceModel.publicIsSecondCategory = false;
                mServiceModel.getCategoryList(mServiceTypeId);
                mServiceListPopwindow.dismiss();
            }
        });
        break;
    case R.id.first_category:
        if (mFirstCategoryListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mFirstCategoryPopWindowView = layoutInflater.inflate(R.layout.first_category_popwindow, null);
            mFirstCategoryPopWindowListView = (ListView) mFirstCategoryPopWindowView
                    .findViewById(R.id.first_category_pop_listview);
            mFirstCategoryListPopwindow = new PopupWindow(mFirstCategoryPopWindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mFirstCategoryPopAdapter == null) {
            mFirstCategoryPopAdapter = new FirstCategoryPopAdapter(this, mFirstCategoryList);
            mFirstCategoryPopWindowListView.setAdapter(mFirstCategoryPopAdapter);
        } else {
            mFirstCategoryPopAdapter.publicFirstCategoryList = mFirstCategoryList;
            mFirstCategoryPopAdapter.notifyDataSetChanged();
        }
        mFirstCategoryListPopwindow.setFocusable(true);
        // ?
        mFirstCategoryListPopwindow.setOutsideTouchable(true);
        mFirstCategoryArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mFirstCategoryListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mFirstCategoryListPopwindow.showAsDropDown(parent);
        mFirstCategoryListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mFirstCategoryArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mFirstCategoryPopWindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_CATEGORY service_category = mFirstCategoryList.get(position);
                mFirstClassServiceCategory = service_category.id;
                mFirstCategoryTitle.setText(service_category.title);
                mServiceModel.publicIsSecondCategory = true;
                mServiceModel.getCategoryList(mFirstClassServiceCategory);
                mFirstCategoryListPopwindow.dismiss();
            }
        });
        break;
    case R.id.second_category:
        if (mSecondCategoryListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mSecondCategoryPopWindowView = layoutInflater.inflate(R.layout.second_category_popwindow, null);
            mSecondCategoryPopWindowListView = (ListView) mSecondCategoryPopWindowView
                    .findViewById(R.id.second_category_pop_listview);
            mSecondCategoryListPopwindow = new PopupWindow(mSecondCategoryPopWindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mSecondCategoryPopAdapter == null) {
            mSecondCategoryPopAdapter = new SecondCategoryPopAdapter(this, mSecondCategoryList);
            mSecondCategoryPopWindowListView.setAdapter(mSecondCategoryPopAdapter);
        } else {
            mSecondCategoryPopAdapter.publicSecondCategoryList = mSecondCategoryList;
            mSecondCategoryPopAdapter.notifyDataSetChanged();
        }

        mSecondCategoryListPopwindow.setFocusable(true);
        // ?
        mSecondCategoryListPopwindow.setOutsideTouchable(true);
        mSecondCategoryArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mSecondCategoryListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mSecondCategoryListPopwindow.showAsDropDown(parent);
        mSecondCategoryListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mSecondCategoryArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mSecondCategoryPopWindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_CATEGORY service_category = mSecondCategoryList.get(position);
                mSecondVlassServiceCategory = service_category.id;
                mSecondCategoryTitle.setText(service_category.title);
                mServiceModel.publicIsSecondCategory = true;
                mSecondCategoryListPopwindow.dismiss();
            }
        });
        break;
    }

}

From source file:de.schildbach.wallet.ui.ChannelRequestActivity.java

private void popup(final View anchor, final View contentView) {
    contentView.measure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, 0),
            View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, 0));

    popupWindow = new PopupWindow(contentView, contentView.getMeasuredWidth(), contentView.getMeasuredHeight(),
            false);//w w  w  .  j a va2 s  . c  om
    popupWindow.showAsDropDown(anchor);

    // hack
    contentView.setBackgroundResource(
            popupWindow.isAboveAnchor() ? R.drawable.popup_frame_above : R.drawable.popup_frame_below);
}

From source file:bmcx.aiton.com.passenger.view.activity.UploadUserDataActivity.java

/**
 * POP?//from w  w w . j a va2s  . co  m
 */
private void showPopupwindowForChooseImageStage() {
    View inflate = getLayoutInflater().inflate(R.layout.layout_pop_choose_img_stage, null);
    inflate.findViewById(R.id.click_local).setOnClickListener(this);
    inflate.findViewById(R.id.click_camera).setOnClickListener(this);
    inflate.findViewById(R.id.cancle).setOnClickListener(this);
    //??truePopupWindow,match??
    mPopupWindow = new PopupWindow(inflate, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, true);
    //
    mPopupWindow.setOutsideTouchable(false);
    //?
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.alpha = 0.7f;
    getWindow().setAttributes(lp);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.alpha = 1f;
            getWindow().setAttributes(lp);
        }
    });
    // ?PopupWindowBackdismiss
    BitmapDrawable bitmapDrawable = new BitmapDrawable();
    mPopupWindow.setBackgroundDrawable(bitmapDrawable);
    mPopupWindow.showAtLocation(inflate, Gravity.BOTTOM, 0, 0);
}

From source file:com.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);//from  w  w  w.  j a va  2 s  .c  om
    View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null);
    final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    //??
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    popupWindow.setWidth(dm.widthPixels);
    popupWindow.setAnimationStyle(R.style.popuwindow);
    //?
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new poponDismissListener_FinancialApplyFragment());

    //PopupWindow-----END
    //PopupWindow
    Button button = (Button) view.findViewById(R.id.take_photo);//??
    Button button1 = (Button) view.findViewById(R.id.all_photo);//?
    Button button2 = (Button) view.findViewById(R.id.out);//?
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,?
            allPhoto();
        }
    });
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,Intent????
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //,??
            File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image");
            //??
            path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg";
            //?IntentIntent?
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
            //?
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            //?Intent??RoundImageView
            startActivityForResult(intent, REQUEST_CODE);
        }
    });
}

From source file:passenger.view.activity.UploadUserDataActivity.java

/**
     * POP?//from   www. j  av  a  2  s. co  m
     */
    private void showPopupwindowForChooseImageStage() {
        View inflate = getLayoutInflater().inflate(R.layout.layout_pop_choose_img_stage, null);
        inflate.findViewById(R.id.click_local).setOnClickListener(this);
        inflate.findViewById(R.id.click_camera).setOnClickListener(this);
        inflate.findViewById(R.id.cancle).setOnClickListener(this);
        //??truePopupWindow,match??
        mPopupWindow = new PopupWindow(inflate, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, true);
        //
        mPopupWindow.setOutsideTouchable(false);
        //?
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = 0.7f;
        getWindow().setAttributes(lp);
        mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

            @Override
            public void onDismiss() {
                WindowManager.LayoutParams lp = getWindow().getAttributes();
                lp.alpha = 1f;
                getWindow().setAttributes(lp);
            }
        });
        // ?PopupWindowBackdismiss
        BitmapDrawable bitmapDrawable = new BitmapDrawable();
        mPopupWindow.setBackgroundDrawable(bitmapDrawable);
        mPopupWindow.showAtLocation(inflate, Gravity.BOTTOM, 0, 0);
    }

From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);/*from  w  w  w  . j  a v a 2s  .co m*/
    View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null);
    final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    //??
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    popupWindow.setWidth(dm.widthPixels);
    popupWindow.setAnimationStyle(R.style.popuwindow);
    //?
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new poponDismissListener_CompanyApplyFragment());

    //PopupWindow-----END
    //PopupWindow
    Button button = (Button) view.findViewById(R.id.take_photo);//??
    Button button1 = (Button) view.findViewById(R.id.all_photo);//?
    Button button2 = (Button) view.findViewById(R.id.out);//?
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,?
            Log.i("Daniel", "------");
            allPhoto();
        }
    });
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,Intent????
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //,??
            File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image");
            //??
            path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg";
            //?IntentIntent?
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
            //?
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            //?Intent??RoundImageView
            startActivityForResult(intent, REQUEST_CODE);
        }
    });
}

From source file:com.watch.customer.ui.ShopListActivity.java

@SuppressWarnings("deprecation")
private void showSectionPop(int width, int height, final int secindex) {
    layout = (LinearLayout) LayoutInflater.from(ShopListActivity.this).inflate(R.layout.popup_category, null);
    section_list = (ListView) layout.findViewById(R.id.section_list);
    section_grid = (GridView) layout.findViewById(R.id.section_grid);
    section_list.setOnItemClickListener(this);
    section_grid.setOnItemClickListener(this);
    if (secindex == 1) {// 2grid
        section_grid.setVisibility(View.VISIBLE);
        section_list.setVisibility(View.GONE);
        secAdapter = new SectionAdapter(ShopListActivity.this, secArr2, selectPos[secindex], secindex);
        section_grid.setAdapter(secAdapter);
    } else {//from  w w w. ja v  a2  s .c om
        section_grid.setVisibility(View.GONE);
        section_list.setVisibility(View.VISIBLE);
        if (secindex == 0) {
            secAdapter = new SectionAdapter(ShopListActivity.this, secArr1, selectPos[secindex], secindex);
        } else {
            secAdapter = new SectionAdapter(ShopListActivity.this, secArr3, selectPos[secindex], secindex);
        }
        section_list.setAdapter(secAdapter);
    }
    mPopWin = new PopupWindow(layout, width, LayoutParams.WRAP_CONTENT, true);
    mPopWin.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss() {
            // TODO Auto-generated method stub
            selectSecCheck(4);
        }
    });
    mPopWin.setBackgroundDrawable(new BitmapDrawable());
    mPopWin.showAsDropDown(text1, 0, 0);
    mPopWin.update();
}