Java 类android.widget.PopupWindow 实例源码

项目:boohee_v5.6    文件:PopupWindowCompatGingerbread.java   
static int getWindowLayoutType(PopupWindow popupWindow) {
    if (!sGetWindowLayoutTypeMethodAttempted) {
        try {
            sGetWindowLayoutTypeMethod = PopupWindow.class.getDeclaredMethod("getWindowLayoutType", new Class[0]);
            sGetWindowLayoutTypeMethod.setAccessible(true);
        } catch (Exception e) {
        }
        sGetWindowLayoutTypeMethodAttempted = true;
    }
    if (sGetWindowLayoutTypeMethod != null) {
        try {
            return ((Integer) sGetWindowLayoutTypeMethod.invoke(popupWindow, new Object[0])).intValue();
        } catch (Exception e2) {
        }
    }
    return 0;
}
项目:GitHub    文件:ReadEPubActivity.java   
private void initTocList() {
    mTocListAdapter = new TocListAdapter(this, mChapterList, "", 1);
    mTocListAdapter.setEpub(true);
    mTocListPopupWindow = new ListPopupWindow(this);
    mTocListPopupWindow.setAdapter(mTocListAdapter);
    mTocListPopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    mTocListPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    mTocListPopupWindow.setAnchorView(mCommonToolbar);
    mTocListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTocListPopupWindow.dismiss();
            currentChapter = position + 1;
            mTocListAdapter.setCurrentChapter(currentChapter);
            viewpager.setCurrentItem(position);
        }
    });
    mTocListPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            toolbarAnimateHide();
        }
    });
}
项目:QMUI_Android    文件:QMUIBasePopup.java   
/**
 * Constructor.
 *
 * @param context Context
 */
public QMUIBasePopup(Context context) {
    mContext = context;
    mWindow = new PopupWindow(context);
    mWindow.setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                mWindow.dismiss();
                return false;
            }
            return false;
        }
    });

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

}
项目:AdvancedTextView    文件:SelectableTextView.java   
/**
 * 长按弹出菜单
 *
 * @param offsetY
 * @param actionMenu
 * @return 菜单创建成功,返回true
 */
private void showActionMenu(int offsetY, ActionMenu actionMenu) {

    mActionMenuPopupWindow = new PopupWindow(actionMenu, WindowManager.LayoutParams.WRAP_CONTENT,
            mActionMenuHeight, true);
    mActionMenuPopupWindow.setFocusable(true);
    mActionMenuPopupWindow.setOutsideTouchable(false);
    mActionMenuPopupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
    mActionMenuPopupWindow.showAtLocation(this, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);

    mActionMenuPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Selection.removeSelection(getEditableText());
            // 如果设置了分散对齐,ActionMenu销毁后,强制刷新一次,防止出现文字背景未消失的情况
            if (isTextJustify)
                SelectableTextView.this.postInvalidate();
        }
    });
}
项目:Tribe    文件:LifeDetailActivity.java   
private void showPopUpWindow(View view) {
    WindowManager systemService = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    int width = systemService.getDefaultDisplay().getWidth();
    int height = systemService.getDefaultDisplay().getHeight();
    int popWidth = (int) (width * 0.75);
    int popHeight = (int) (height * 0.64);
    PopupWindow popupWindow = new PopupWindow(this);
    popupWindow.setWidth(popWidth);
    popupWindow.setHeight(popHeight);
    View inflate = LayoutInflater.from(this).inflate(R.layout.ll_life_detail_pop,null);
    popupWindow.setContentView(inflate);
    popupWindow.setClippingEnabled(false);//设置覆盖状态栏,重点
    popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.rl_pop_top_corner));
    popupWindow.setOutsideTouchable(false);
    popupWindow.setFocusable(true);
    popupWindow.showAtLocation(view, Gravity.CENTER,0,0);

    initPopUpView(inflate);

}
项目:GitHub    文件:CustomPopWindow.java   
/**
 * 添加一些属性设置
 * @param popupWindow
 */
private void apply(PopupWindow popupWindow){
    popupWindow.setClippingEnabled(mClippEnable);
    if(mIgnoreCheekPress){
        popupWindow.setIgnoreCheekPress();
    }
    if(mInputMode!=-1){
        popupWindow.setInputMethodMode(mInputMode);
    }
    if(mSoftInputMode!=-1){
        popupWindow.setSoftInputMode(mSoftInputMode);
    }
    if(mOnDismissListener!=null){
        popupWindow.setOnDismissListener(mOnDismissListener);
    }
    if(mOnTouchListener!=null){
        popupWindow.setTouchInterceptor(mOnTouchListener);
    }
    popupWindow.setTouchable(mTouchable);



}
项目:GongXianSheng    文件:ProductTypePopup.java   
private void init(){
        View view = LayoutInflater.from(context).inflate(R.layout.popup_tab_type, null);
        setContentView(view);
        setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        setBackgroundDrawable(new ColorDrawable(0x66000000));
        setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        setFocusable(false);
        setOutsideTouchable(false);
        mLayoutContainer = (ViewGroup)view.findViewById(R.id.layout_tab_container);

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

//        setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                ivOpen.setImageResource(R.drawable.arrow);
//            }
//        });
    }
项目:lqrwechatrongcloud    文件:PopupWindowUtils.java   
/**
 * 得到一个自动识别在目标控件上方或下方的pupupwindow并显示
 *
 * @param contentView popupwindow要显示的视图
 * @param width       popupwindow的宽度
 * @param activity    能得到getWindowManager()的上下文
 * @return
 */
public static PopupWindow getPopupWindowAsDropDownParentAuto(View contentView, int width, int height, View anchorView, Activity activity) {

    //        View itemView = (View) contentView.getParent();// 得到contentView的父控件
    PopupWindow popupWindow = getPopupWindow(contentView, width, height);

    // 控制它放置的位置
    if (isShowBottom(activity, anchorView)) {// 显示popupwindow在itemView的下方,偏移量都为0
        popupWindow.showAsDropDown(anchorView, 0, 0);
    } else {// 显示popupwindow在itemView的上方,偏移量y都为-2*itemView.getHeight()
        popupWindow.showAsDropDown(anchorView, 0,
                -2 * anchorView.getHeight());
    }

    return popupWindow;
}
项目:CCDownload    文件:PopMenu.java   
public PopMenu(Context context, int resid, int checkedPosition, int height) {
        this.context = context;
        this.checkedPosition = checkedPosition;

        itemList = new ArrayList<String>();
        RelativeLayout view = new RelativeLayout(context);
//      view.setBackgroundResource(resid);

        listView = new ListView(context);
        listView.setPadding(0, ParamsUtil.dpToPx(context, 3), 0, ParamsUtil.dpToPx(context, 3));
        view.addView(listView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        listView.setAdapter(new PopAdapter());
        listView.setOnItemClickListener(this);

        popupWindow = new PopupWindow(view, context.getResources().getDimensionPixelSize(R.dimen.popmenu_width), height);
        popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0)));
    }
项目:MyRepository    文件:ScanImagesActivity.java   
/**
 * 初始化显示文件夹信息的popupWindow
 */
private void initPopupWindow() {
    popRecyclerview = new RecyclerView(this);
    popRecyclerview.setBackgroundColor(getResources().getColor(android.R.color.white));
    LinearLayoutManager layoutManager = new LinearLayoutManager
            (this, LinearLayoutManager.VERTICAL, false);
    popRecyclerview.setLayoutManager(layoutManager);
    popRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
    popRecyclerview.setPadding(0, Commonutil.dp2px(this, 5), 0, 0);

    int screenHeight = getResources().getDisplayMetrics().heightPixels;

    popupWindow = new PopupWindow(popRecyclerview, ViewGroup.LayoutParams.MATCH_PARENT,
            (int) (screenHeight * 0.6f));

    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(false);
    popupWindow.setAnimationStyle(R.style.popup_anim);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            fab.setVisibility(View.VISIBLE);
            WindowManager.LayoutParams attributes =
                    ScanImagesActivity.this.getWindow().getAttributes();
            attributes.alpha = 1;
            ScanImagesActivity.this.getWindow().setAttributes(attributes);
        }
    });

}
项目:yyox    文件:ListFilePopWindow.java   
public ListFilePopWindow(Context context, View targetView) {
    super();
    this.targetView = targetView;
    View contentView = LayoutInflater.from(context).inflate(R.layout.kf5_list_file_dir, null);
    listView = (ListView) contentView.findViewById(R.id.kf5_list_dir);
    Point point = ScreenUtils.getScreenSize(context);
    int height = (int) (point.y * (4.5f / 8.0f));
    popupWindow = new PopupWindow();
    popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    popupWindow.setHeight(height);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setTouchable(true);
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            // TODO Auto-generated method stub
            popupWindow.dismiss();
        }
    });
    popupWindow.setAnimationStyle(R.style.KF5FileListPopAnim);
    popupWindow.setContentView(contentView);
    listView.setOnItemClickListener(this);
}
项目:QMUI_Android    文件:QMUIBasePopup.java   
/**
 * Set content view.
 *
 * @param root Root view
 */
public void setContentView(View root) {
    if (root == null)
        throw new IllegalStateException("setContentView was not called with a view to display.");
    mRootViewWrapper = new RootView(mContext);
    mRootViewWrapper.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mRootView = root;
    mRootViewWrapper.addView(root);
    mWindow.setContentView(mRootViewWrapper);
    mWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            QMUIBasePopup.this.onDismiss();
            if (mDismissListener != null) {
                mDismissListener.onDismiss();
            }
        }
    });
}
项目:AssistantBySDK    文件:ChooseSetPopupWindow.java   
private void initView() {
    View contentView = LayoutInflater.from(mContext).inflate(R.layout.popup_choose_set, null);
    contentView.findViewById(R.id.ll_shade).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mChooseWindow = new PopupWindow(contentView, -1, -1);
    //点击空白处的时候PopupWindow会消失
    mChooseWindow.setFocusable(true);
    mChooseWindow.setTouchable(true);
    mChooseWindow.setOutsideTouchable(true);
    mChooseWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // mChooseWindow.setAnimationStyle(R.style.popupAnim);

    //初始化集数列表
    RecyclerView rvChooseSet = (RecyclerView) contentView.findViewById(R.id.rv_choose_set);
    rvChooseSet.setHasFixedSize(true);
    rvChooseSet.setLayoutManager(new GridLayoutManager(mContext, 4));
    rvChooseSet.setAdapter(new ChooseSetAdapter());
}
项目:letv    文件:AlbumHalfCommentController.java   
public void showPopupWindow(View target) {
    if (target != null) {
        if (this.morePopupWindow == null) {
            this.morePopupWindow = new PopupWindow(this.context);
            this.morePopupWindow.setBackgroundDrawable(new BitmapDrawable());
            this.morePopupWindow.setWidth(UIsUtils.zoomWidth(60));
            this.morePopupWindow.setHeight(UIsUtils.zoomWidth(40));
            this.morePopupWindow.setOutsideTouchable(true);
            this.morePopupWindow.setFocusable(true);
            this.morePopupWindow.setContentView(this.popupContentView);
        }
        int[] location = new int[2];
        target.getLocationOnScreen(location);
        LogInfo.log("Emerson", "-----------location[1] = " + location[1]);
        LogInfo.log("fornia", "location[0]:" + location[0] + "  location[1]:" + location[1]);
        this.morePopupWindow.showAtLocation(target, 0, location[0] + ((target.getWidth() - UIsUtils.dipToPx(40.0f)) / 2), (location[1] + (target.getHeight() / 2)) - UIsUtils.dipToPx(60.0f));
        this.morePopupWindow.update();
    }
}
项目:TextReader    文件:ReadEPubActivity.java   
private void initTocList() {
    mTocListAdapter = new TocListAdapter(this, mChapterList, "", 1);
    mTocListAdapter.setEpub(true);
    mTocListPopupWindow = new ListPopupWindow(this);
    mTocListPopupWindow.setAdapter(mTocListAdapter);
    mTocListPopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    mTocListPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    mTocListPopupWindow.setAnchorView(mCommonToolbar);
    mTocListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTocListPopupWindow.dismiss();
            currentChapter = position + 1;
            mTocListAdapter.setCurrentChapter(currentChapter);
            viewpager.setCurrentItem(position);
        }
    });
    mTocListPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            toolbarAnimateHide();
        }
    });
}
项目:Renrentou    文件:CitySelectFragment.java   
private void initPopUp(){
    popupView = getActivity().getLayoutInflater().inflate(R.layout.popupwindow_city_select, null);
    mPopupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
    mPopupWindow.setTouchable(true);
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
    popupView.findViewById(R.id.select_confirm).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            provinceTv.setText(currentProvince.getAreaName());
            cityTv.setText(currentCity.getAreaName());
            countyTv.setText(currentCounty.getAreaName());
            mPopupWindow.dismiss();
        }
    });
}
项目:Simpler    文件:WebViewActivity.java   
/**
 * 显示PopupWindow:WebView操作
 *
 * @param view
 */
private void showWebViewOpWindow(View view) {
    View contentView = getLayoutInflater().inflate(R.layout.window_webview_op, null);
    // 设置Item的点击事件
    LinearLayout llRefresh = (LinearLayout) contentView.findViewById(R.id.llRefresh);
    LinearLayout llCopyUrl = (LinearLayout) contentView.findViewById(R.id.llCopyUrl);
    LinearLayout llOpen = (LinearLayout) contentView.findViewById(R.id.llOpen);

    final PopupWindow popupWindow = new PopupWindow(contentView,
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT, true);

    OpClickListener listener = new OpClickListener(popupWindow);
    llRefresh.setOnClickListener(listener);
    llCopyUrl.setOnClickListener(listener);
    llOpen.setOnClickListener(listener);

    // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
    popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.popup_transparent_bg));

    // 设置好参数之后再show
    popupWindow.showAsDropDown(view);
}
项目:PopupWindow    文件:PopupActivity.java   
@Override
public void onClick(View v) {
    PopupWindow win=window.getPopupWindow();
    switch (v.getId()) {
        case R.id.translate_bt:
            win.setAnimationStyle(R.style.animTranslate);
            break;
        case R.id.alpha_bt:
            win.setAnimationStyle(R.style.animAlpha);
            break;
        case R.id.scale_bt:
            win.setAnimationStyle(R.style.animScale);
            break;
        case R.id.rotate_bt:
            win.setAnimationStyle(R.style.animRotate);
            break;
        default:break;
    }
    window.showAtLocation(activityPopup, Gravity.BOTTOM, 0, 0);
    WindowManager.LayoutParams lp=getWindow().getAttributes();
    lp.alpha=0.3f;
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    getWindow().setAttributes(lp);
}
项目:QMUI_Android    文件:QDPopupFragment.java   
private void initNormalPopupIfNeed() {
    if (mNormalPopup == null) {
        mNormalPopup = new QMUIPopup(getContext(), QMUIPopup.DIRECTION_NONE);
        TextView textView = new TextView(getContext());
        textView.setLayoutParams(mNormalPopup.generateLayoutParam(
                QMUIDisplayHelper.dp2px(getContext(), 250),
                WRAP_CONTENT
        ));
        textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
        int padding = QMUIDisplayHelper.dp2px(getContext(), 20);
        textView.setPadding(padding, padding, padding, padding);
        textView.setText("Popup 可以设置其位置以及显示和隐藏的动画");
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
        mNormalPopup.setContentView(textView);
        mNormalPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mActionButton1.setText(getContext().getResources().getString(R.string.popup_normal_action_button_text_show));
            }
        });
    }
}
项目:qmui    文件:QDPopupFragment.java   
private void initNormalPopupIfNeed() {
    if (mNormalPopup == null) {
        mNormalPopup = new QMUIPopup(getContext(), QMUIPopup.DIRECTION_NONE);
        TextView textView = new TextView(getContext());
        textView.setLayoutParams(mNormalPopup.generateLayoutParam(
                QMUIDisplayHelper.dp2px(getContext(), 250),
                WRAP_CONTENT
        ));
        textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
        int padding = QMUIDisplayHelper.dp2px(getContext(), 20);
        textView.setPadding(padding, padding, padding, padding);
        textView.setText("Popup 可以设置其位置以及显示和隐藏的动画");
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.app_color_description));
        mNormalPopup.setContentView(textView);
        mNormalPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mActionButton1.setText(getContext().getResources().getString(R.string.popup_normal_action_button_text_show));
            }
        });
    }
}
项目:letv    文件:AlbumCommentDetailActivity.java   
public void showPopupWindow(View target) {
    if (target != null) {
        if (this.morePopupWindow == null) {
            this.morePopupWindow = new PopupWindow(BaseApplication.getInstance());
            this.morePopupWindow.setBackgroundDrawable(new BitmapDrawable());
            this.morePopupWindow.setWidth(UIsUtils.zoomWidth(60));
            this.morePopupWindow.setHeight(UIsUtils.zoomWidth(40));
            this.morePopupWindow.setOutsideTouchable(true);
            this.morePopupWindow.setFocusable(true);
            this.morePopupWindow.setContentView(this.popupContentView);
        }
        int[] location = new int[2];
        target.getLocationOnScreen(location);
        LogInfo.log("Emerson", "-----------location[1] = " + location[1]);
        this.morePopupWindow.showAtLocation(target, 0, location[0] + ((target.getWidth() - UIsUtils.dipToPx(40.0f)) / 2), (location[1] + (target.getHeight() / 2)) - UIsUtils.dipToPx(60.0f));
        this.morePopupWindow.update();
    }
}
项目:MinimalismJotter    文件:AlbumActivity.java   
/**
 * 初始化展示文件夹的popupWindw
 */
private void initListDirPopupWindw() {
    mListImageDirPopupWindow = new ListImageDirPopupWindow(
            LayoutParams.MATCH_PARENT, (int) (mScreenHeight * 0.7),
            mImageFloders, LayoutInflater.from(getApplicationContext())
            .inflate(R.layout.list_dir, null));

    mListImageDirPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            // 设置背景颜色变暗
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.alpha = 1.0f;
            getWindow().setAttributes(lp);
        }
    });
    // 设置选择文件夹的回调
    mListImageDirPopupWindow.setOnImageDirSelected(this);
}
项目:mvvm-template    文件:AnimHelper.java   
@UiThread public static void revealPopupWindow(@NonNull PopupWindow popupWindow, @NonNull View from) {
    Rect rect = ViewHelper.getLayoutPosition(from);
    int x = (int) rect.exactCenterX();
    int y = (int) rect.exactCenterY();
    if (popupWindow.getContentView() != null) {
        View view = popupWindow.getContentView();
        if (view != null) {
            popupWindow.showAsDropDown(from);
            view.post(() -> {
                if (ViewCompat.isAttachedToWindow(view)) {
                    Animator animator = ViewAnimationUtils.createCircularReveal(view, x, y, 0,
                            (float) Math.hypot(rect.width(), rect.height()));
                    animator.setDuration(view.getResources().getInteger(android.R.integer.config_shortAnimTime));
                    animator.start();
                }
            });
        }
    }
}
项目:letv    文件:SweepActivity.java   
private void OpenHelpWindows() {
    this.mNotToSweep = true;
    View mDialogView = getLayoutInflater().inflate(R.layout.activity_sweep_help_viewpager, null, false);
    this.mSweepHelpView = new SweepHelpView(mDialogView);
    this.mSweepHelpView.initView();
    final PopupWindow helpPopup = DialogUtils.dialog(mDialogView, 0, 0, 0, 0, -1, -1);
    this.mIsHelpViewShow = true;
    this.mSweepHelpView.setOnCloseListener(new IFunction<Void>() {
        public Void get() {
            SweepActivity.this.mIsHelpViewShow = false;
            SweepActivity.this.initSweep();
            DialogUtils.closeDialog(helpPopup);
            SweepActivity.this.mLastObjString = null;
            if (!NetworkUtil.isNetAvailable()) {
                SweepActivity.this.mNotToSweep = true;
                if (!SweepActivity.this.mIsPermissionTipShow) {
                    SweepActivity.this.openNoNewworkTip();
                }
            }
            return null;
        }
    });
}
项目:Demos    文件:FillBlankView.java   
@Override
public void onClick(final View widget) {
    View view = LayoutInflater.from(context).inflate(R.layout.layout_input, null);
    final EditText etInput = (EditText) view.findViewById(R.id.et_answer);
    Button btnFillBlank = (Button) view.findViewById(R.id.btn_fill_blank);

    // 显示原有答案
    String oldAnswer = answerList.get(position);
    if (!TextUtils.isEmpty(oldAnswer)) {
        etInput.setText(oldAnswer);
        etInput.setSelection(oldAnswer.length());
    }

    final PopupWindow popupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT, dp2px(40));
    // 获取焦点
    popupWindow.setFocusable(true);
    // 为了防止弹出菜单获取焦点之后,点击Activity的其他组件没有响应
    popupWindow.setBackgroundDrawable(new PaintDrawable());
    // 设置PopupWindow在软键盘的上方
    popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    // 弹出PopupWindow
    popupWindow.showAtLocation(tvContent, Gravity.BOTTOM, 0, 0);

    btnFillBlank.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // 填写答案
            String answer = etInput.getText().toString();
            fillAnswer(answer, position);
            popupWindow.dismiss();
        }
    });

    // 显示软键盘
    InputMethodManager inputMethodManager =
            (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
项目:LQRWeChat-master    文件:PopupWindowUtils.java   
/**
 * 得到在屏幕中间的popupwindow并显示(宽高都是包裹视图)
 *
 * @param contentView popupwindow要显示的视图
 * @param parentView  参考视图
 * @return
 */
public static PopupWindow getPopupWindowInCenter(View contentView, View parentView) {
    //        int width = ViewGroup.LayoutParams.MATCH_PARENT;
    int width = ViewGroup.LayoutParams.WRAP_CONTENT;
    int height = ViewGroup.LayoutParams.WRAP_CONTENT;

    return getPopupWindowInCenter(contentView, width, height, parentView);
}
项目:GitHub    文件:ReadActivity.java   
@OnClick(R.id.tvBookReadToc)
public void onClickToc() {
    gone(rlReadAaSet, rlReadMark);
    if (!mTocListPopupWindow.isShowing()) {
        visible(mTvBookReadTocTitle);
        gone(mTvBookReadReading, mTvBookReadCommunity, mTvBookReadChangeSource);
        mTocListPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        mTocListPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        mTocListPopupWindow.show();
        mTocListPopupWindow.setSelection(currentChapter - 1);
        mTocListPopupWindow.getListView().setFastScrollEnabled(true);
    }
}
项目:GitHub    文件:FolderWindow.java   
public static void setPopupWindowTouchModal(PopupWindow popupWindow, boolean touchModal) {
    if (null == popupWindow) {
        return;
    }
    Method method;
    try {
        method = PopupWindow.class.getDeclaredMethod("setTouchModal",boolean.class);
        method.setAccessible(true);
        method.invoke(popupWindow, touchModal);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:GitHub    文件:EasyPopActivity.java   
private void initAbovePop() {
    mAbovePop = new EasyPopup(this)
            .setContentView(R.layout.layout_any)
            .setFocusAndOutsideEnable(true)
            .setOnDismissListener(new PopupWindow.OnDismissListener() {
                @Override
                public void onDismiss() {
                    Log.e(TAG, "onDismiss: mAbovePop");
                }
            })
            .createPopup();
}
项目:BookReader-master    文件:SearchActivity.java   
@Override
public void showAutoCompleteList(List<String> list) {
    mAutoList.clear();
    mAutoList.addAll(list);

    if (!mListPopupWindow.isShowing()) {
        mListPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        mListPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        mListPopupWindow.show();
    }
    mAutoAdapter.notifyDataSetChanged();

}
项目:FastLib    文件:PopupWindowUtil.java   
/**
 * 展示popupWindow--解决Android 7.0版本兼容性问题
 *
 * @param mWindow PopupWindow
 * @param anchor  the view on which to pin the popup window
 * @param x       A horizontal offset from the anchor in pixels
 * @param y       A vertical offset from the anchor in pixels
 */
public static void showAsDropDown(PopupWindow mWindow, View anchor, int x, int y) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
        int[] location = new int[2];
        anchor.getLocationOnScreen(location);
        mWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, location[0] + x, location[1] + anchor.getHeight() + y);
    } else {
        mWindow.showAsDropDown(anchor, x, y);
    }
}
项目:Blockly    文件:BasicFieldColorViewTest.java   
@Test
public void testPopupWindowProperties() {
    mFieldColorView.performClick();
    final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow();

    assertThat(popupWindow).isNotNull();
    assertThat(popupWindow.isShowing()).isTrue();
    assertThat(popupWindow.isTouchable()).isTrue();
    assertThat(popupWindow.isFocusable()).isTrue();
}
项目:backup    文件:RestoreBackupActivityController.java   
private PopupWindow buildPopupWindow(Activity parent) {
    LayoutInflater inflater = (LayoutInflater) parent.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ViewGroup popupViewGroup = parent.findViewById(R.id.popup_layout);
    View popupView = inflater.inflate(R.layout.progress_popup_window, popupViewGroup);

    PopupWindow popupWindow = new PopupWindow(popupView, 750, 350, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    popupWindow.setElevation(10);
    popupWindow.setFocusable(false);
    popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
    return popupWindow;
}
项目:boohee_v5.6    文件:CustomUnitPopupWindow.java   
private void createPopWindow(Context context, String unit_name) {
    if (this.mContext != context) {
        this.mContext = context;
        this.mCurrentUnitName = unit_name;
        this.popWindow = new PopupWindow(createContentView(), -1, -2, true);
        this.popWindow.setBackgroundDrawable(new BitmapDrawable());
        this.popWindow.setFocusable(true);
        this.popWindow.setTouchable(true);
        this.popWindow.setOutsideTouchable(true);
        this.inAnim = AnimationUtils.loadAnimation(this.mContext, R.anim.s);
    }
}
项目:TextReader    文件:ReadActivity.java   
@OnClick(R.id.tvBookReadToc)
public void onClickToc() {
    gone(rlReadAaSet, rlReadMark);
    if (!mTocListPopupWindow.isShowing()) {
        visible(mTvBookReadTocTitle);
        gone(mTvBookReadReading, mTvBookReadCommunity, mTvBookReadChangeSource);
        mTocListPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        mTocListPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        mTocListPopupWindow.show();
        mTocListPopupWindow.setSelection(currentChapter - 1);
        mTocListPopupWindow.getListView().setFastScrollEnabled(true);
    }
}
项目:CSipSimple    文件:MenuPopupHelper.java   
public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);

    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);

    View anchor = mAnchorView;
    if (anchor != null) {
        // Don't attach to the VTO unless the anchor itself is attached to avoid VTO-related leaks.
        if (anchor.getWindowToken() != null) {
            ViewTreeObserver vto = anchor.getViewTreeObserver();
            if (vto != mTreeObserver) {
                if (mTreeObserver != null && mTreeObserver.isAlive()) {
                    mTreeObserver.removeGlobalOnLayoutListener(this);
                }
                if ((mTreeObserver = vto) != null) {
                    vto.addOnGlobalLayoutListener(this);
                }
            }
        } else if (anchor instanceof View_HasStateListenerSupport) {
            ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        }
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }

    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
项目:android-project-gallery    文件:BaseFragmentActivity.java   
/**
 * 显示底部菜单栏
 * 
 * @param popupWindow
 */
public void showBottomPopupMenu(final PopupWindow popupWindow, final int background)
{
    popupWindow.showAtLocation(rocky_rootView, Gravity.BOTTOM, 0, 0);
    getUiHandler().postDelayed(new Runnable()
    {

        @Override
        public void run()
        {
            setBottomPopupMenuBackground(background);
            setBottomPopupMenuVisibility(View.VISIBLE);
        }
    }, 500);
}
项目:FamilyBond    文件:CustomPopupWindow.java   
private CustomPopupWindow(Builder builder) {

        if (builder.contentViewId == 0 || builder.width == 0 || builder.height == 0) {
            throw new IllegalArgumentException("The parameter is incomplete, be sure to contain contentView, width and height.");
        }

        mContext = builder.context;
        mContentView = LayoutInflater.from(mContext).inflate(builder.contentViewId, null);
        mPopupWindow = new PopupWindow(mContentView, builder.width, builder.height, builder.focus);

        if (Build.VERSION.SDK_INT >= 21) mPopupWindow.setElevation(builder.elevation);
        mPopupWindow.setOutsideTouchable(builder.outsideCancel);
        mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mPopupWindow.setAnimationStyle(builder.animStyle);
    }
项目:android-project-gallery    文件:BaseFragmentActivity.java   
/**
 * 隐藏底部菜单栏
 * 
 * @param popupWindow
 */
public void dismissBottomPopupMenu(final PopupWindow popupWindow)
{
    setBottomPopupMenuVisibility(View.GONE);
    getUiHandler().post(new Runnable()
    {

        @Override
        public void run()
        {
            popupWindow.dismiss();
        }
    });
}
项目:CSipSimple    文件:IcsListPopupWindow.java   
public void run() {
    if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() &&
            mDropDownList.getChildCount() <= mListItemExpandMaximum) {
        mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
        show();
    }
}