List of usage examples for android.widget PopupWindow setOutsideTouchable
public void setOutsideTouchable(boolean touchable)
Controls whether the pop-up will be informed of touch events outside of its window.
From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java
private void ChangeIcon() { //PopupWindow----START-----??PopupWindowPopupWindow??? backgroundAlpha(0.3f);/*from ww w .j a v a2s . c o 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); //// w ww .j ava 2 s . c o 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.zia.freshdocs.widget.adapter.CMISAdapter.java
/** * Display file information/* ww w . j a va 2 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:com.duy.pascal.ui.debug.activities.DebugActivity.java
@WorkerThread private void showPopupAt(final LineNumber lineNumber, final String msg) { mHandler.post(new Runnable() { @Override//from w ww . j a v a 2 s .c om public void run() { if (isFinishing()) return; //get relative position of expression at edittext Point position = mCodeView.getDebugPosition(lineNumber.getLine(), lineNumber.getColumn(), Gravity.TOP); DLog.d(TAG, "generate: " + position); dismissPopup(); //create new popup PopupWindow window = new PopupWindow(DebugActivity.this); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View container = inflater.inflate(R.layout.popup_expr_result, null); container.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); int windowHeight = container.getMeasuredHeight(); int windowWidth = container.getMeasuredWidth(); window.setContentView(container); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setTouchable(true); window.setSplitTouchEnabled(true); window.setOutsideTouchable(true); window.showAtLocation(mCodeView, Gravity.NO_GRAVITY, position.x - windowWidth / 3, position.y + toolbar.getHeight() - windowHeight); TextView txtResult = container.findViewById(R.id.txt_result); txtResult.setText(msg); AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.5f); alphaAnimation.setDuration(1000); alphaAnimation.setRepeatMode(Animation.REVERSE); alphaAnimation.setRepeatCount(Animation.INFINITE); txtResult.startAnimation(alphaAnimation); DebugActivity.this.mPopupWindow = window; } }); }
From source file:org.onebusaway.android.ui.ArrivalsListHeader.java
/** * Sets the popup for the status/*from w ww .j a v a2s .c o m*/ * * @param index 0 if this is for the top ETA row, 1 if it is for the second * @param color color resource id to use for the popup background * @param statusText text to show in the status popup * @return a new PopupWindow initialized based on the provided parameters */ private PopupWindow setupPopup(final int index, int color, String statusText) { LayoutInflater inflater = LayoutInflater.from(mContext); TextView statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_large, null); statusView.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) statusView.getBackground(); if (color != R.color.stop_info_ontime) { // Show early/late color d.setColor(mResources.getColor(color)); } else { // For on-time, use header default color d.setColor(mResources.getColor(R.color.theme_primary)); } d.setStroke(UIUtils.dpToPixels(mContext, 1), mResources.getColor(R.color.header_text_color)); int pSides = UIUtils.dpToPixels(mContext, 5); int pTopBottom = UIUtils.dpToPixels(mContext, 2); statusView.setPadding(pSides, pTopBottom, pSides, pTopBottom); statusView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); statusView.measure(TextView.MeasureSpec.UNSPECIFIED, TextView.MeasureSpec.UNSPECIFIED); statusView.setText(statusText); PopupWindow p = new PopupWindow(statusView, statusView.getWidth(), statusView.getHeight()); p.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); p.setBackgroundDrawable(new ColorDrawable(mResources.getColor(android.R.color.transparent))); p.setOutsideTouchable(true); p.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { boolean touchInView; if (index == 0) { touchInView = UIUtils.isTouchInView(mEtaAndMin1, event); } else { touchInView = UIUtils.isTouchInView(mEtaAndMin2, event); } return touchInView; } }); return p; }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
private void commonPopupWindowDisplay(PopupWindow popupWindow, View tabMenu, int x, int y) { popupWindow.setFocusable(true);//from w ww . j a v a 2s . c o m popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setIgnoreCheekPress(); popupWindow.setOutsideTouchable(true); popupWindow.showAsDropDown(tabMenu, x, y); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
public void showPreviews(final View anchor, int start, int end) { if (mWorkspace != null && mWorkspace.getChildCount() > 0) { if (newPreviews) { showingPreviews = true;/* w w w. j ava 2s .c om*/ hideDesktop(true); mWorkspace.lock(); mWorkspace.openSense(true); } else { // check first if it's already open final PopupWindow window = (PopupWindow) anchor.getTag(R.id.TAG_PREVIEW); if (window != null) return; Resources resources = getResources(); PersonaWorkspace personaWorkspace = mWorkspace; PersonaCellLayout cell = ((PersonaCellLayout) personaWorkspace.getChildAt(start)); float max; ViewGroup preview; max = personaWorkspace.getChildCount(); preview = new LinearLayout(this); Rect r = new Rect(); // ADW: seems sometimes this throws an out of memory error.... // so... try { resources.getDrawable(R.drawable.pr_preview_background).getPadding(r); } catch (OutOfMemoryError e) { } int extraW = (int) ((r.left + r.right) * max); int extraH = r.top + r.bottom; int aW = cell.getWidth() - extraW; float w = aW / max; int width = cell.getWidth(); int height = cell.getHeight(); // width -= (x + cell.getRightPadding()); // height -= (y + cell.getBottomPadding()); if (width != 0 && height != 0) { showingPreviews = true; float scale = w / width; int count = end - start; final float sWidth = width * scale; float sHeight = height * scale; PreviewTouchHandler handler = new PreviewTouchHandler(anchor); ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(count); for (int i = start; i < end; i++) { ImageView image = new ImageView(this); cell = (PersonaCellLayout) personaWorkspace.getChildAt(i); Bitmap bitmap = Bitmap.createBitmap((int) sWidth, (int) sHeight, Bitmap.Config.ARGB_8888); cell.setDrawingCacheEnabled(false); Canvas c = new Canvas(bitmap); c.scale(scale, scale); c.translate(-cell.getLeftPadding(), -cell.getTopPadding()); cell.dispatchDraw(c); image.setBackgroundDrawable(resources.getDrawable(R.drawable.pr_preview_background)); image.setImageBitmap(bitmap); image.setTag(i); image.setOnClickListener(handler); image.setOnFocusChangeListener(handler); image.setFocusable(true); if (i == mWorkspace.getCurrentScreen()) image.requestFocus(); preview.addView(image, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); bitmaps.add(bitmap); } PopupWindow p = new PopupWindow(this); p.setContentView(preview); p.setWidth((int) (sWidth * count + extraW)); p.setHeight((int) (sHeight + extraH)); p.setAnimationStyle(R.style.AnimationPreview); p.setOutsideTouchable(true); p.setFocusable(true); p.setBackgroundDrawable(new ColorDrawable(0)); p.showAsDropDown(anchor, 0, 0); p.setOnDismissListener(new PopupWindow.OnDismissListener() { public void onDismiss() { dismissPreview(anchor); } }); anchor.setTag(R.id.TAG_PREVIEW, p); anchor.setTag(R.id.workspace, preview); anchor.setTag(R.id.icon, bitmaps); } } } }