Example usage for android.widget PopupWindow setBackgroundDrawable

List of usage examples for android.widget PopupWindow setBackgroundDrawable

Introduction

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

Prototype

public void setBackgroundDrawable(Drawable background) 

Source Link

Document

Specifies the background drawable for this popup window.

Usage

From source file:com.kccomy.orgar.ui.note.NoteFragment.java

private void initPopupWindow() {
    View popupWindowView = getActivity().getLayoutInflater().inflate(R.layout.popup_window_share, null);

    //??// w  w w .  j  a  v  a  2  s.c  o  m
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addCategory(Intent.CATEGORY_DEFAULT);
    shareIntent.setType("text/plain");

    PackageManager packageManager = getContext().getPackageManager();
    List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(shareIntent,
            PackageManager.GET_RESOLVED_FILTER);

    // RecyclerAdapter
    RecyclerView recyclerView = (RecyclerView) popupWindowView.findViewById(R.id.popup_widow_share_recycler);
    ShareAdapter shareAdapter = new ShareAdapter(packageManager);
    shareAdapter.setData(resolveInfos);
    shareAdapter.setAppIconClickListener(shareListener);

    recyclerView.setAdapter(shareAdapter);
    recyclerView
            .setLayoutManager(new GridLayoutManager(getContext(), 2, LinearLayoutManager.HORIZONTAL, false));

    // ?PopupWindow
    popupWindowView.setFocusable(true);
    popupWindowView.setFocusableInTouchMode(true);

    PopupWindow popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);

    popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));

    popupWindow.setAnimationStyle(R.style.anim_menu_bottombar);

    setWindowAlpha(0.5f);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            setWindowAlpha(1f);
        }
    });

    popupWindow.showAtLocation(getActivity().getLayoutInflater().inflate(R.layout.fragment_note, null),
            Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
}

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

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);// ww  w. java  2s . 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:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);/*from   w  w w  . ja  v  a2 s.  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:org.zywx.wbpalmstar.plugin.uexPopoverMenu.EUExPopoverMenu.java

private void showPopoverMenu(double x, double y, int direction, String bgColorStr, String dividerColor,
        String textColor, int textSize, JSONArray data) {
    LinearLayout rootView = (LinearLayout) LayoutInflater.from(mContext)
            .inflate(finder.getLayoutId("plugin_uex_popovermenu"), null);

    final PopupWindow popupWindow = new PopupWindow(rootView, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, true);

    popupWindow.setContentView(rootView);
    ////from   w w w .  j  ava  2s .co  m
    rootView.setBackgroundColor(Color.parseColor(bgColorStr));
    popupWindow.setContentView(rootView);
    //popupWindow?
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setOutsideTouchable(true);

    int length = data.length();
    List<ItemData> itemDataList = new ArrayList<ItemData>();
    try {
        for (int i = 0; i < length; i++) {
            ItemData item = new ItemData();
            String icon = data.getJSONObject(i).optString("icon", "");
            if (!hasIcon && !TextUtils.isEmpty(icon)) {
                hasIcon = true;
            }
            if (hasIcon) {
                item.setIcon(data.getJSONObject(i).getString("icon"));
            }
            item.setText(data.getJSONObject(i).getString("text"));
            itemDataList.add(item);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < length; i++) {
        LinearLayout linearLayout = new LinearLayout(mContext);
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        if (hasIcon) {
            ImageView imageView = new ImageView(mContext);
            imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            String imagePath = itemDataList.get(i).getIcon();
            imageView.setImageBitmap(getBitmapFromPath(imagePath));
            imageView.setPadding(DensityUtil.dip2px(mContext, 5), 0, 0, 0);
            linearLayout.addView(imageView);
        }
        TextView tvText = new TextView(mContext);
        LinearLayout.LayoutParams tvLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tvLayoutParams.gravity = Gravity.CENTER_VERTICAL;
        tvText.setLayoutParams(tvLayoutParams);

        tvText.setPadding(DensityUtil.dip2px(mContext, 5), 0, DensityUtil.dip2px(mContext, 8), 0);
        tvText.setText(itemDataList.get(i).getText());
        tvText.setTextColor(Color.parseColor(textColor));
        tvText.setTextSize(textSize);
        linearLayout.addView(tvText);
        linearLayout.setTag(i);
        linearLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                callBackPluginJs(CALLBACK_ITEM_SELECTED, String.valueOf(v.getTag()));
                if (popupWindow != null && popupWindow.isShowing()) {
                    popupWindow.dismiss();
                }
            }
        });
        rootView.addView(linearLayout);

        //
        View dividerLine = new View(mContext);
        dividerLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                DensityUtil.dip2px(mContext, 1)));
        dividerLine.setBackgroundColor(Color.parseColor(dividerColor));
        rootView.addView(dividerLine);
    }
    int gravityParam;
    switch (direction) {
    case 0:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    case 1:
        gravityParam = Gravity.RIGHT | Gravity.TOP;
        break;
    case 2:
        gravityParam = Gravity.LEFT | Gravity.BOTTOM;
        break;
    case 3:
        gravityParam = Gravity.RIGHT | Gravity.BOTTOM;
        break;
    default:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    }
    popupWindow.showAtLocation(mBrwView.getRootView(), gravityParam, (int) x, (int) y);
}

From source file:com.dycody.android.idealnote.SketchFragment.java

private void showPopup(View anchor, final int eraserOrStroke) {

    boolean isErasing = eraserOrStroke == SketchView.ERASER;

    oldColor = mColorPicker.getColor();/*from  w  ww  .ja  va  2s . c o m*/

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

    // Creating the PopupWindow
    PopupWindow popup = new PopupWindow(getActivity());
    popup.setContentView(isErasing ? popupEraserLayout : popupLayout);
    popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setFocusable(true);
    popup.setOnDismissListener(() -> {
        if (mColorPicker.getColor() != oldColor)
            mColorPicker.setOldCenterColor(oldColor);
    });

    // Clear the default translucent background
    popup.setBackgroundDrawable(new BitmapDrawable());

    // Displaying the popup at the specified location, + offsets (transformed 
    // dp to pixel to support multiple screen sizes)
    popup.showAsDropDown(anchor);

    // Stroke size seekbar initialization and event managing
    SeekBar mSeekBar;
    mSeekBar = (SeekBar) (isErasing ? popupEraserLayout.findViewById(R.id.stroke_seekbar)
            : popupLayout.findViewById(R.id.stroke_seekbar));
    mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // When the seekbar is moved a new size is calculated and the new shape
            // is positioned centrally into the ImageView
            setSeekbarProgress(progress, eraserOrStroke);
        }
    });
    int progress = isErasing ? seekBarEraserProgress : seekBarStrokeProgress;
    mSeekBar.setProgress(progress);
}

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

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

    mChatListView = (ListView) v.findViewById(R.id.chat_list_view);

    // TODO: ?//from  w  w  w  . j  a va 2 s.  com
    mSourceDataList = new ArrayList<ChatListDataModel>();
    ChatListDataModel sourceData = new ChatListDataModel();
    sourceData.setChatAvatar(R.drawable.default_contact_action_01);
    sourceData.setChatTitle("?");
    sourceData.setChatSummary(":?, ...");
    mSourceDataList.add(sourceData);

    ChatListDataModel sourceData1 = new ChatListDataModel();
    sourceData1.setChatAvatar(R.drawable.default_contact_action_04);
    sourceData1.setChatTitle("");
    sourceData1.setChatSummary("?");
    mSourceDataList.add(sourceData1);

    ChatListDataModel sourceData2 = new ChatListDataModel();
    sourceData2.setChatAvatar(R.drawable.default_contact_action_03);
    sourceData2.setChatTitle("");
    sourceData2.setChatSummary("?...");
    mSourceDataList.add(sourceData2);

    ChatListDataModel sourceData3 = new ChatListDataModel();
    sourceData3.setChatAvatar(R.drawable.default_contact_action_02);
    sourceData3.setChatTitle("");
    sourceData3.setChatSummary("?");
    mSourceDataList.add(sourceData3);

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

    mChatListAdapter = new ChatListAdapter(this.getActivity(), mSourceDataList);
    mChatListView.setAdapter(mChatListAdapter);
    mChatListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (DEBUG)
                Log.d(TAG, mSourceDataList.get(i).getChatTitle());

            Intent intent = new Intent(getActivity(), ChatFormActivity.class);
            getActivity().startActivity(intent);
            getActivity().finish();
            // ?
            getActivity().overridePendingTransition(R.anim.activity_open_enter, R.anim.activity_close_exit);

        }
    });
    mChatListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) {
            if (DEBUG)
                Log.d(TAG, mSourceDataList.get(i).getChatTitle());

            // ??
            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).getChatTitle());

                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;
        }
    });
    // mChatListView.setOnItemSelectedListener();

    // #ContextMenu
    // this.unregisterForContextMenu(mChatListView);
    // mChatListView.setOnCreateContextMenuListener(null);
    // this.registerForContextMenu(mChatListView);
    return v;
}

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 .  ja  v  a2 s. c om
    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.zia.freshdocs.widget.adapter.CMISAdapter.java

/**
 * Display file information/*  w w  w . j av  a2  s  .  co m*/
 * 
 * @param context
 */

public void showFileInfo(Context context, int position, boolean isFile) {

    final NodeRef ref = getItem(position);
    try {
        //We need to get the instance of the LayoutInflater, use the context of this activity
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //Inflate the view from a predefined XML layout
        View layout = inflater.inflate(R.layout.file_info_dialog, null, false);
        // create a WRAP_CONTENT PopupWindow
        PopupWindow mPopUp = new PopupWindow(layout, WindowManager.LayoutParams.FILL_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT, true);
        mPopUp.setBackgroundDrawable(new BitmapDrawable());
        mPopUp.setOutsideTouchable(true);
        // display the popup in the center
        mPopUp.showAtLocation(layout, Gravity.CENTER, 0, 0);

        TextView title = (TextView) layout.findViewById(R.id.dialog_title);
        if (isFile)
            title.setText(context.getString(R.string.str_file_information));
        else
            title.setText(context.getString(R.string.str_folder_information));

        UITableView tableView = (UITableView) layout.findViewById(R.id.tableView);

        ViewItem viewItem;

        if (ref.getName() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_name), ref.getName());
            tableView.addViewItem(viewItem);
        }
        if (ref.getCreateBy() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_created_by),
                    ref.getCreateBy());
            tableView.addViewItem(viewItem);
        }

        if (ref.getLastModificationDate() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_last_modification_date),
                    ref.getLastModificationDate());
            tableView.addViewItem(viewItem);
        }

        if (ref.getLastModifiedBy() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_last_modified_by),
                    ref.getLastModifiedBy());
            tableView.addViewItem(viewItem);
        }

        if (ref.getContent() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_content),
                    ref.getContent());
            tableView.addViewItem(viewItem);
        }

        if (ref.getContentType() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_content_type),
                    ref.getContentType());
            tableView.addViewItem(viewItem);
        }

        if (ref.getObjectId() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_object_id),
                    ref.getObjectId());
            tableView.addViewItem(viewItem);
        }

        if (ref.getParentId() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_parent_id),
                    ref.getParentId());
            tableView.addViewItem(viewItem);
        }

        if (ref.getVersion() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_version),
                    ref.getVersion());
            tableView.addViewItem(viewItem);
        }

        tableView.commit();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java

private void showPopup() {
    if (mScrollState != AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
        return;//from w ww.j a va  2s.  c  o m
    }

    if (mPopup == null) {
        PopupWindow p = new PopupWindow(this);
        p.setFocusable(false);
        p.setContentView(mPopupPosition);
        p.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        p.setBackgroundDrawable(null);
        p.setAnimationStyle(android.R.style.Animation_Dialog);
        mPopup = p;
    }

    if (mNarratives.getWindowVisibility() == View.VISIBLE) {
        mPopup.showAtLocation(mNarratives, Gravity.CENTER, 0, 0);
    }
}

From source file:com.vanisty.ui.MenuActivity.java

private void showPopup(final Activity context, Point p) {
    int popupWidth = 200;
    int popupHeight = 150;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popup);
    LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = layoutInflater.inflate(R.layout.popup_layout, viewGroup);

    // Creating the PopupWindow
    final PopupWindow popup = new PopupWindow(context);
    popup.setContentView(layout);/*from   w  ww . j  a va  2 s  . co  m*/
    popup.setWidth(popupWidth);
    popup.setHeight(popupHeight);
    popup.setFocusable(true);

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

    // Clear the default translucent background
    popup.setBackgroundDrawable(new BitmapDrawable());

    // Displaying the popup at the specified location, + offsets.
    popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y);

    // Getting a reference to Close button, and close the popup when clicked.
    Button close = (Button) layout.findViewById(R.id.close);
    close.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            popup.dismiss();
        }
    });
}