当前位置: 首页>>代码示例>>Java>>正文


Java PopupWindow类代码示例

本文整理汇总了Java中android.widget.PopupWindow的典型用法代码示例。如果您正苦于以下问题:Java PopupWindow类的具体用法?Java PopupWindow怎么用?Java PopupWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PopupWindow类属于android.widget包,在下文中一共展示了PopupWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWindowLayoutType

import android.widget.PopupWindow; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:PopupWindowCompatGingerbread.java

示例2: initTocList

import android.widget.PopupWindow; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:ReadEPubActivity.java

示例3: QMUIBasePopup

import android.widget.PopupWindow; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:23,代码来源:QMUIBasePopup.java

示例4: showActionMenu

import android.widget.PopupWindow; //导入依赖的package包/类
/**
 * 长按弹出菜单
 *
 * @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();
        }
    });
}
 
开发者ID:devilist,项目名称:AdvancedTextView,代码行数:27,代码来源:SelectableTextView.java

示例5: showPopUpWindow

import android.widget.PopupWindow; //导入依赖的package包/类
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);

}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:21,代码来源:LifeDetailActivity.java

示例6: apply

import android.widget.PopupWindow; //导入依赖的package包/类
/**
 * 添加一些属性设置
 * @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);



}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:CustomPopWindow.java

示例7: init

import android.widget.PopupWindow; //导入依赖的package包/类
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);
//            }
//        });
    }
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:25,代码来源:ProductTypePopup.java

示例8: getPopupWindowAsDropDownParentAuto

import android.widget.PopupWindow; //导入依赖的package包/类
/**
 * 得到一个自动识别在目标控件上方或下方的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;
}
 
开发者ID:lo625090140,项目名称:lqrwechatrongcloud,代码行数:24,代码来源:PopupWindowUtils.java

示例9: PopMenu

import android.widget.PopupWindow; //导入依赖的package包/类
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)));
	}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:18,代码来源:PopMenu.java

示例10: initPopupWindow

import android.widget.PopupWindow; //导入依赖的package包/类
/**
 * 初始化显示文件夹信息的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);
        }
    });

}
 
开发者ID:BittleDragon,项目名称:MyRepository,代码行数:35,代码来源:ScanImagesActivity.java

示例11: ListFilePopWindow

import android.widget.PopupWindow; //导入依赖的package包/类
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);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:27,代码来源:ListFilePopWindow.java

示例12: setContentView

import android.widget.PopupWindow; //导入依赖的package包/类
/**
 * 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();
            }
        }
    });
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:24,代码来源:QMUIBasePopup.java

示例13: initView

import android.widget.PopupWindow; //导入依赖的package包/类
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());
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:23,代码来源:ChooseSetPopupWindow.java

示例14: showPopupWindow

import android.widget.PopupWindow; //导入依赖的package包/类
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();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:AlbumHalfCommentController.java

示例15: initPopUp

import android.widget.PopupWindow; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:17,代码来源:CitySelectFragment.java


注:本文中的android.widget.PopupWindow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。