List of usage examples for android.widget PopupWindow setFocusable
public void setFocusable(boolean focusable)
Changes the focusability of the popup window.
From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java
private void showColorChoosePop() { LinearLayout linearLayout = new LinearLayout(this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); int margin = EUExUtil.dipToPixels(8); lp.setMargins(margin / 2, margin, margin / 2, margin); linearLayout.setLayoutParams(lp);/*from w w w . ja va 2 s .c o m*/ linearLayout.setOrientation(LinearLayout.HORIZONTAL); for (int color : colors) { linearLayout.addView(getColorImageView(color)); } HorizontalScrollView scrollView = new HorizontalScrollView(this); LinearLayout.LayoutParams scrollLp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); scrollView.setLayoutParams(scrollLp); scrollView.addView(linearLayout); int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); scrollView.measure(w, h); PopupWindow popupWindow = new PopupWindow(scrollView); popupWindow.setBackgroundDrawable(new ColorDrawable()); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setWidth(mImageContentLayout.getWidth()); popupWindow.setHeight(scrollView.getMeasuredHeight()); popupWindow.showAtLocation(mImageContentLayout, Gravity.BOTTOM, 0, mCloseLayout.getHeight() + mBrushLayout.getHeight() + popupWindow.getHeight()); }
From source file:com.kccomy.orgar.ui.note.NoteFragment.java
private void initPopupWindow() { View popupWindowView = getActivity().getLayoutInflater().inflate(R.layout.popup_window_share, null); //??//from w w w.j av a 2 s. c om 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.dycody.android.idealnote.SketchFragment.java
private void showPopup(View anchor, final int eraserOrStroke) { boolean isErasing = eraserOrStroke == SketchView.ERASER; oldColor = mColorPicker.getColor();/* w w w. ja va 2s. co 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:cn.zhangls.android.weibo.ui.weibo.WeiboFrameProvider.java
/** * ????/*w w w .j a v a 2s .c o m*/ * * @param holder * @param status */ private void setupPopupBar(final FrameHolder holder, final Status status) { LayoutInflater layoutInflater = LayoutInflater .from(holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext()); // final View popupView; if (status.isFavorited() && status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_save_post, holder.binding.flWeiboContainer, false); } else if (!status.isFavorited() && status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_unsave_post, holder.binding.flWeiboContainer, false); } else if (status.isFavorited() && !status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_save_post, holder.binding.flWeiboContainer, false); } else {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_unsave_post, holder.binding.flWeiboContainer, false); } // PopupWindow final PopupWindow popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); // popupWindow popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { Animation animation = AnimationUtils.loadAnimation( holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(), R.anim.rotate_180_end); animation.setDuration(300); animation.setFillAfter(true); holder.binding.fgHomeWeiboPopupBar.startAnimation(animation); } }); popupWindow.setAnimationStyle(R.style.PopupWindowAnimStyle); // popupWindow Item ? if (status.isFavorited()) {// ?????? popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_save_post) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FavoritesAPI favoritesAPI = new FavoritesAPI( mBinding.getRoot().getContext().getApplicationContext(), AccessTokenKeeper.readAccessToken( mBinding.getRoot().getContext().getApplicationContext())); BaseObserver<Favorite> observer = new BaseObserver<Favorite>( mBinding.getRoot().getContext().getApplicationContext()) { @Override public void onNext(Favorite value) { } @Override public void onError(Throwable e) { super.onError(e); } @Override public void onComplete() { } }; favoritesAPI.destroy(observer, status.getId()); popupWindow.dismiss(); } }); } else { popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unsave_post) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FavoritesAPI favoritesAPI = new FavoritesAPI( mBinding.getRoot().getContext().getApplicationContext(), AccessTokenKeeper.readAccessToken( mBinding.getRoot().getContext().getApplicationContext())); BaseObserver<Favorite> observer = new BaseObserver<Favorite>( mBinding.getRoot().getContext().getApplicationContext()) { @Override public void onNext(Favorite value) { } @Override public void onError(Throwable e) { super.onError(e); } @Override public void onComplete() { } }; favoritesAPI.create(observer, status.getId()); popupWindow.dismiss(); } }); } if (status.getUser().isFollowing()) {// ???? popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_follow) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); } else { popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unfollow) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); } // ??? holder.binding.fgHomeWeiboPopupBar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (popupWindow != null && !popupWindow.isShowing()) { Animation animation = AnimationUtils.loadAnimation( holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(), R.anim.rotate_180_start); animation.setDuration(300); animation.setFillAfter(true); holder.binding.fgHomeWeiboPopupBar.startAnimation(animation); popupWindow.showAsDropDown(holder.binding.fgHomeWeiboPopupBar); } } }); }
From source file:bruce.kk.brucetodos.MainActivity.java
/** * ? //from ww w.j av a 2 s . c o m */ private void showAddPop() { final EditText editText = new EditText(MainActivity.this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editText.setLayoutParams(layoutParams); // editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); editText.setTextColor(getResources().getColor(android.R.color.holo_green_light)); editText.setHint("?~"); editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark)); editText.setBackgroundColor(getResources().getColor(android.R.color.black)); final PopupWindow popupWindow = new PopupWindow(editText, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ? popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { LogDetails.d(": " + editText.getText().toString()); if (!TextUtils.isEmpty(editText.getText().toString().trim())) { ProgressDialogUtils.showProgressDialog(); UnFinishItem item = new UnFinishItem(); Date date = new Date(); item.createDay = date; item.content = editText.getText().toString().trim(); item.modifyDay = date; dataList.add(item); refreshData(true); presenter.addItem(item); } } }); }
From source file:bruce.kk.brucetodos.MainActivity.java
/** * ???/*ww w.j a v a 2 s . com*/ * * @param position */ private void modifyItem(final int position) { final UnFinishItem item = dataList.get(position); LogDetails.d(item); LinearLayout linearLayout = new LinearLayout(MainActivity.this); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearLayout.setLayoutParams(layoutParams); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setBackgroundColor(getResources().getColor(android.R.color.black)); final EditText editText = new EditText(MainActivity.this); editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); editText.setTextColor(getResources().getColor(android.R.color.holo_green_light)); editText.setHint(item.content); editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark)); linearLayout.addView(editText); Button btnModify = new Button(MainActivity.this); btnModify.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); btnModify.setText(""); btnModify.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); btnModify.setTextColor(getResources().getColor(android.R.color.holo_blue_bright)); btnModify.setBackgroundColor(getResources().getColor(android.R.color.black)); linearLayout.addView(btnModify); Button btnDeleteItem = new Button(MainActivity.this); btnDeleteItem.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); btnDeleteItem.setText(""); btnDeleteItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); btnDeleteItem.setTextColor(getResources().getColor(android.R.color.holo_blue_bright)); btnDeleteItem.setBackgroundColor(getResources().getColor(android.R.color.black)); linearLayout.addView(btnDeleteItem); final PopupWindow popupWindow = new PopupWindow(linearLayout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ? popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0); btnModify.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { LogDetails.d(": " + editText.getText().toString()); if (!TextUtils.isEmpty(editText.getText().toString().trim())) { Date date = new Date(); item.content = editText.getText().toString().trim(); item.modifyDay = date; item.finishDay = null; ProgressDialogUtils.showProgressDialog(); presenter.modifyItem(item); dataList.set(position, item); refreshData(true); popupWindow.dismiss(); } else { Toast.makeText(MainActivity.this, "~", Toast.LENGTH_SHORT).show(); } } }); btnDeleteItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dataList.remove(position); presenter.deleteItem(item); refreshData(false); popupWindow.dismiss(); } }); }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
private void showPopup() { if (mScrollState != AbsListView.OnScrollListener.SCROLL_STATE_FLING) { return;//from w w w.j a v a 2 s . co 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.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java
private void ChangeIcon() { //PopupWindow----START-----??PopupWindowPopupWindow??? backgroundAlpha(0.3f);//from w ww .jav a2 s. c om View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null); final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); //?? DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); popupWindow.setWidth(dm.widthPixels); popupWindow.setAnimationStyle(R.style.popuwindow); //? popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); popupWindow.setOnDismissListener(new poponDismissListener_FinancialApplyFragment()); //PopupWindow-----END //PopupWindow Button button = (Button) view.findViewById(R.id.take_photo);//?? Button button1 = (Button) view.findViewById(R.id.all_photo);//? Button button2 = (Button) view.findViewById(R.id.out);//? button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,? allPhoto(); } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,Intent???? Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //,?? File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image"); //?? path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg"; //?IntentIntent? intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path))); //? intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //?Intent??RoundImageView startActivityForResult(intent, REQUEST_CODE); } }); }
From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java
private void showPopup(View anchor, final int eraserOrStroke) { boolean isErasing = eraserOrStroke == SketchView.ERASER; oldColor = mColorPicker.getColor();//from w ww. j a v a 2 s . c om 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(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { 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: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 .ja v a 2 s . c o 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(); } }); }