Java Code Examples for android.widget.PopupWindow#setFocusable()
The following examples show how to use
android.widget.PopupWindow#setFocusable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationToast.java From NewsMe with Apache License 2.0 | 6 votes |
public AnimationToast(Context context, View view, int bgResId, int textSizeResId) { if (view instanceof TextView) { mTextView = (TextView) view; } // mPopToast = new PopupWindow(view, width, height); mPopToast = new PopupWindow(view); // mPopToast.setAnimationStyle(DEFAULT_ANIMATION_STYLE); mPopToast.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); // int drawableBg = context.getResources().getIdentifier( // "toast_animation_bg", "drawable", context.getPackageName()); Resources resources = context.getResources(); float value = resources.getDisplayMetrics().scaledDensity; mTextView.setTextSize(resources.getDimension(textSizeResId) / value); mPopToast.setBackgroundDrawable(resources.getDrawable(bgResId)); mPopToast.setFocusable(false); // mPopToast.setOutsideTouchable(true); }
Example 2
Source File: ShoppingDetailActivity.java From ShoppingCartActivity with Apache License 2.0 | 6 votes |
/** * 弹出悬浮窗体,显示菜单 */ private void popuWindowDialog() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.task_detail_popupwindow, null); LinearLayout linMessage= (LinearLayout) layout.findViewById(R.id.popuMessage); LinearLayout linMain= (LinearLayout) layout.findViewById(R.id.popuMain); LinearLayout linShare= (LinearLayout) layout.findViewById(R.id.popuShare); linMessage.setOnClickListener(this); linMain.setOnClickListener(this); linShare.setOnClickListener(this); pwMyPopWindow = new PopupWindow(layout); pwMyPopWindow.setFocusable(true); // 加上这个popupwindow中的ListView才可以接收点击事件 // 控制popupwindow的宽度和高度自适应 pwMyPopWindow.setWidth(400); pwMyPopWindow.setHeight(300); // 触摸popupwindow外部,popupwindow消失。这个要求你的popupwindow要有背景图片才可以成功,如上 pwMyPopWindow.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.bg_popupwindow)); // 控制popupwindow点击屏幕其他地方消失 pwMyPopWindow.setOutsideTouchable(true); }
Example 3
Source File: ImagePickerFloderPop.java From FamilyChat with Apache License 2.0 | 6 votes |
public ImagePickerFloderPop(Activity context, ImageFloderBean curFloder, ImagePickerGridPresenter presenter) { this.mContext = context; this.mCurFloder = curFloder; this.mPresenter = presenter; this.mAllFloderList = mPresenter.getAllFloderList(); mLayout = LayoutInflater.from(context).inflate(R.layout.layout_imagepicker_floder_pop, null); mPop = new PopupWindow(mLayout, RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT, true); mPop.setBackgroundDrawable(new BitmapDrawable());// 响应返回键必须的语句。 mPop.setFocusable(true);//设置pop可获取焦点 mPop.setAnimationStyle(R.style.FloderPopAnimStyle);//设置显示、消失动画 mPop.setOutsideTouchable(true);//设置点击外部可关闭pop mPop.setOnDismissListener(this); mListView = (ListView) mLayout.findViewById(R.id.lv_floderpop); ImagePickerFloderAdapter adapter = new ImagePickerFloderAdapter(context, mAllFloderList, curFloder); mListView.setAdapter(adapter); mListView.setOnItemClickListener(this); mLayout.findViewById(R.id.view_floderpop_bg).setOnClickListener(this); }
Example 4
Source File: BootstrapDropDown.java From Android-Bootstrap with MIT License | 6 votes |
private void createDropDown() { ScrollView dropdownView = createDropDownView(); dropdownWindow = new PopupWindow(); dropdownWindow.setFocusable(true); dropdownWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); if (!isInEditMode()) { dropdownWindow.setBackgroundDrawable(DrawableUtils.resolveDrawable(android.R.drawable .dialog_holo_light_frame, getContext())); } dropdownWindow.setContentView(dropdownView); dropdownWindow.setOnDismissListener(this); dropdownWindow.setAnimationStyle(android.R.style.Animation_Activity); float longestStringWidth = measureStringWidth(getLongestString(dropdownData)) + DimenUtils.dpToPixels((baselineItemRightPadding + baselineItemLeftPadding) * bootstrapSize); if (longestStringWidth < getMeasuredWidth()) { dropdownWindow.setWidth(DimenUtils.dpToPixels(getMeasuredWidth())); } else { dropdownWindow.setWidth((int) longestStringWidth + DimenUtils.dpToPixels(8)); } }
Example 5
Source File: MainActivity.java From qingyang with Apache License 2.0 | 6 votes |
/** * 显示菜单 * * @param x * @param y */ public void showPopMenu(int x, int y) { LinearLayout layout = (LinearLayout) LayoutInflater.from( MainActivity.this).inflate(R.layout.pop_menu, null); ListView listView = (ListView) layout.findViewById(R.id.menu_list); listView.setAdapter(new ArrayAdapter<String>(MainActivity.this, R.layout.pop_menu_item, R.id.tv_text, title)); popupWindow = new PopupWindow(MainActivity.this); popupWindow.setBackgroundDrawable(new BitmapDrawable()); if (application.isTablet()) { popupWindow.setWidth(screenWidth / 4); } else { popupWindow.setWidth(screenWidth / 3); } popupWindow.setHeight(LayoutParams.WRAP_CONTENT); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); popupWindow.setContentView(layout); // 需要指定Gravity,默认情况是center popupWindow.showAtLocation(view, Gravity.RIGHT | Gravity.TOP, x, y); listView.setOnItemClickListener(new MenuItemClick()); }
Example 6
Source File: JkChatActivity.java From HttpRequest with Apache License 2.0 | 6 votes |
/** * 复制、删除窗体显示 * @author leibing * @createTime 2017/5/5 * @lastModify 2017/5/5 * @param v 位置参照物 * @param onClick 点击事件 * @return */ private void showPopUps(View v, View.OnClickListener onClick){ View popLayout = LayoutInflater.from(this).inflate(R.layout.pop_jk_chat, null); TextView copyTv = (TextView) popLayout.findViewById(R.id.tv_pop_jk_copy); TextView delTv = (TextView) popLayout.findViewById(R.id.tv_pop_jk_del); copyTv.setOnClickListener(onClick); delTv.setOnClickListener(onClick); popupWindow = new PopupWindow(popLayout, 240, 100); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setBackgroundDrawable(new BitmapDrawable()); int[] location = new int[2]; v.getLocationOnScreen(location); popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0] + v.getMeasuredWidth() / 3, location[1]-popupWindow.getHeight()); }
Example 7
Source File: MainActivity.java From BlogPracticeDems with Apache License 2.0 | 6 votes |
private void showPopAlongView(View v) { View view = View.inflate(this, R.layout.pop_layout, null); view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int measureHeight = view.getMeasuredHeight(); int measureWidth = view.getMeasuredWidth(); popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setFocusable(false); popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000)); popupWindow.setOutsideTouchable(false); int[] location = new int[2]; v.getLocationOnScreen(location); popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0] + v.getMeasuredWidth() / 2 - measureWidth / 2, location[1] - measureHeight); orginalX = location[0] + v.getMeasuredWidth() / 2 - measureWidth / 2; originalY = location[1] - measureHeight; popWidth = measureWidth; popHeight = measureHeight; }
Example 8
Source File: SelectRemindCyclePopup.java From Android-AlarmManagerClock with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") public SelectRemindCyclePopup(Context context) { mContext = context; mPopupWindow = new PopupWindow(context); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setWidth(WindowManager.LayoutParams.FILL_PARENT); mPopupWindow.setHeight(WindowManager.LayoutParams.FILL_PARENT); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setAnimationStyle(R.style.AnimBottom); mPopupWindow.setContentView(initViews()); mPopupWindow.getContentView().setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mPopupWindow.setFocusable(false); // mPopupWindow.dismiss(); return true; } }); }
Example 9
Source File: BasePop.java From FamilyChat with Apache License 2.0 | 5 votes |
private void initPop() { mPopupWindow = new PopupWindow(mContext); mPopupWindow.setFocusable(setFocusable()); boolean outsideTouchacle = setOutsideTouchable(); mPopupWindow.setOutsideTouchable(outsideTouchacle); mPopupWindow.setBackgroundDrawable(new ShapeDrawable()); mPopupWindow.setWidth(setLayoutWidthParams()); mPopupWindow.setHeight(setLayoutHeightParams()); int animStyle = setAnimStyle(); if (animStyle != 0) mPopupWindow.setAnimationStyle(animStyle); //设置内容布局 mContentView = mContext.getLayoutInflater().inflate(setContentViewId() , (ViewGroup) mContext.findViewById(android.R.id.content), false); mContentView.measure(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); mPopupWindow.setContentView(mContentView); //设置点击外部关闭pop if (outsideTouchacle) mPopupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { mPopupWindow.dismiss(); return true; } return false; } }); }
Example 10
Source File: MediaController.java From MyHearts with Apache License 2.0 | 5 votes |
private void initFloatingWindow() { mWindow = new PopupWindow(mContext); mWindow.setFocusable(false); mWindow.setBackgroundDrawable(null); mWindow.setOutsideTouchable(true); mAnimStyle = android.R.style.Animation; }
Example 11
Source File: MediaController.java From MeiZiNews with MIT License | 5 votes |
private void initFloatingWindow() { mWindow = new PopupWindow(mContext); mWindow.setFocusable(false); mWindow.setBackgroundDrawable(null); mWindow.setOutsideTouchable(true); mAnimStyle = android.R.style.Animation; }
Example 12
Source File: MediaController.java From qiniu-lab-android with MIT License | 5 votes |
private void initFloatingWindow() { mWindow = new PopupWindow(mContext); mWindow.setFocusable(false); mWindow.setBackgroundDrawable(null); mWindow.setOutsideTouchable(true); mAnimStyle = android.R.style.Animation; }
Example 13
Source File: MediaController.java From Vitamio with Apache License 2.0 | 5 votes |
private void initFloatingWindow() { mWindow = new PopupWindow(mContext); mWindow.setFocusable(false); mWindow.setBackgroundDrawable(null); mWindow.setOutsideTouchable(true); mAnimStyle = android.R.style.Animation; }
Example 14
Source File: SandBoxActivity.java From ToDay with MIT License | 5 votes |
private void displayStatsPopup(View anchor) { LayoutInflater layoutInflater = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_window_flow_stats, null); RelativeLayout viewGroup = (RelativeLayout) layout.findViewById(R.id.popup_stats); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(layout, RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); TextView elementCount = (TextView) viewGroup.findViewById(R.id.stats_total_elements); TextView timeEstimate = (TextView) viewGroup.findViewById(R.id.stats_total_time); TextView completeCount = (TextView) viewGroup.findViewById(R.id.stats_times_complete); TextView lifeTimeInFlow = (TextView) viewGroup.findViewById(R.id.stats_life_time_spent_in_flow); elementCount.setText( String.valueOf(currentToDay.getChildCount()) ); timeEstimate.setText( String.valueOf(currentToDay.getFormattedTime()) ); completeCount.setText( String.valueOf(currentToDay.getCompletionTokens()) ); lifeTimeInFlow.setText( String.valueOf( AppUtils.buildTimerStyleTime(currentToDay.getLifeTimeInToDay())) ); popup.setBackgroundDrawable(new BitmapDrawable(null,"")); popup.setFocusable(true); popup.showAsDropDown(anchor); }
Example 15
Source File: MainActivity.java From xmpp with Apache License 2.0 | 5 votes |
/** * 初始化popupwindow */ private void initialPopup() { LayoutInflater inflater = LayoutInflater.from(this); // 引入窗口配置文件 View view = inflater.inflate(R.layout.third_image_popupwindow, null); view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); // 创建PopupWindow对象 pop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false); pop.setOnDismissListener(this); rl_pop_null = (RelativeLayout) view .findViewById(R.id.third_popupwindow_layout_null); tv_pop_status = (TextView) view .findViewById(R.id.third_popupwindow_textView_status); tv_pop_quxiao = (TextView) view .findViewById(R.id.third_popupwindow_textView_quxiao); tv_pop_chakan = (TextView) view .findViewById(R.id.third_popupwindow_textView_look); tv_pop_change = (TextView) view .findViewById(R.id.third_popupwindow_textView_change); rl_pop_null.setOnClickListener(this); tv_pop_quxiao.setOnClickListener(this); tv_pop_status.setOnClickListener(this); tv_pop_chakan.setOnClickListener(this); tv_pop_change.setOnClickListener(this); // 需要设置一下此参数,点击外边可消失 pop.setBackgroundDrawable(new BitmapDrawable()); // 设置点击窗口外边窗口消失 pop.setOutsideTouchable(true); // 设置此参数获得焦点,否则无法点击 pop.setFocusable(true); initialPopups(); }
Example 16
Source File: MovementTrackActivity.java From RunMap with Apache License 2.0 | 5 votes |
private void showShareLayout() { mSharePopWindow = new PopupWindow(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); View view = LayoutInflater.from(this).inflate(R.layout.sharelayout, null); view.findViewById(R.id.btn_share_to_circle).setOnClickListener(this); view.findViewById(R.id.btn_share_to_friend).setOnClickListener(this); mSharePopWindow.setContentView(view); mSharePopWindow.setFocusable(false); mSharePopWindow.setBackgroundDrawable(new BitmapDrawable()); mSharePopWindow.setOutsideTouchable(true); mSharePopWindow.showAtLocation(findViewById(android.R.id.content), Gravity.BOTTOM,0,0); }
Example 17
Source File: ReactionsPopup.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
/** * Constructor to create a new reactions popup with an anchor view. * * @param context Context the reactions popup is running in, through which it * can access the current theme, resources, etc. * @param anchor Anchor view for this popup. The popup will appear on top of */ public ReactionsPopup(@NonNull Context context, @NonNull View anchor) { this.anchorView = anchor; popup = new PopupWindow(); popup.setWindowLayoutMode(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); reactionsView = new ReactionsView(context); reactionsView.setVisibility(View.VISIBLE); popup.setContentView(reactionsView); popup.setFocusable(true); popup.setClippingEnabled(true); popup.setBackgroundDrawable( ContextCompat.getDrawable(context, R.drawable.rounded_corners_reactions)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { popup.setElevation(10); } reactionsView.setCallback(reactionType -> { if (reactionClickListener != null) { reactionClickListener.onReactionItemClick(reactionType); } }); popup.setOnDismissListener(() -> { if (onDismissListener != null) { onDismissListener.onDismiss(reactionsView); } }); }
Example 18
Source File: IdentitySettingsActivity.java From secure-quick-reliable-login with MIT License | 4 votes |
public void setupSavePopupWindow(LayoutInflater layoutInflater) { View popupView = layoutInflater.inflate(R.layout.fragment_save_settings, null); savePopupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true); savePopupWindow.setTouchable(true); savePopupWindow.setFocusable(true); final EditText txtPassword = popupView.findViewById(R.id.txtPassword); SQRLStorage storage = SQRLStorage.getInstance(IdentitySettingsActivity.this.getApplicationContext()); popupView.findViewById(R.id.btnCloseSaveSettings).setOnClickListener(v -> savePopupWindow.dismiss()); final Button btnSaveSettings = popupView.findViewById(R.id.btnSaveSettings); btnSaveSettings.setOnClickListener(v -> new Thread(() -> { handler.post(() -> { savePopupWindow.dismiss(); showProgressPopup(); }); storage.clearQuickPass(); boolean decryptStatus = storage.decryptIdentityKey(txtPassword.getText().toString(), entropyHarvester, false); if(!decryptStatus) { showErrorMessage(R.string.decrypt_identity_fail); storage.clearQuickPass(); storage.clear(); handler.post(() -> { hideProgressPopup(); txtPassword.setText(""); }); return; } int quickPassLength = getIntValue(txtQuickPassLength); int passwordVerify = getIntValue(txtPwdVerifySecs); int quickPassTimeout = getIntValue(txtQuickPassTimeout); storage.setHintLength(quickPassLength); storage.setPasswordVerify(passwordVerify); storage.setIdleTimeout(quickPassTimeout); storage.setSQRLOnly(cbSQRLOnly.isChecked()); storage.setNoByPass(cbNoBypass.isChecked()); boolean encryptStatus = storage.encryptIdentityKey(txtPassword.getText().toString(), entropyHarvester); if (!encryptStatus) { showErrorMessage(R.string.encrypt_identity_fail); handler.post(() -> { hideProgressPopup(); txtPassword.setText(""); }); return; } storage.clear(); storage.clearQuickPass(); long currentId = SqrlApplication.getCurrentId(this.getApplication()); mDbHelper.updateIdentityData(currentId, storage.createSaveData()); handler.post(() -> { txtPassword.setText(""); hideProgressPopup(); IdentitySettingsActivity.this.finish(); }); }).start()); }
Example 19
Source File: StarkSpinner.java From SSForms with GNU General Public License v3.0 | 4 votes |
private void init() { setupColors(); setupList(); mSearchEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); mStartSearchImageView.setOnClickListener(this); mDoneSearchImageView.setOnClickListener(this); mSearchEditText.addTextChangedListener(mTextWatcher); mPopupWindow = new PopupWindow(mContext); mPopupWindow.setContentView(mSpinnerListContainer); mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { hideEdit(); } }); mPopupWindow.setFocusable(false); mPopupWindow.setElevation(DefaultElevation); mPopupWindow.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.spinner_drawable)); mSpinnerListView.setOnItemClickListener(mOnItemSelectedListener); if (mCurrSelectedView == null) { if (!TextUtils.isEmpty(mSearchHintText)) { mSearchEditText.setHint(mSearchHintText); } if (!TextUtils.isEmpty(mNoItemsFoundText)) { mEmptyTextView.setText(mNoItemsFoundText); } if (mCurrSelectedView == null && !TextUtils.isEmpty(mRevealEmptyText)) { TextView textView = new TextView(mContext); textView.setText(mRevealEmptyText); mCurrSelectedView = new SelectedView(textView, -1, 0); mRevealItem.addView(textView); } } else { mSpinnerListView.performItemClick(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId()); } clearAnimation(); clearFocus(); }
Example 20
Source File: PlayerFragment.java From edx-app-android with Apache License 2.0 | 4 votes |
private void showSettingsPopup(final Point p) { try{ if(player!=null){ player.getController().setAutoHide(!getTouchExploreEnabled()); Activity context = getActivity(); float popupHeight = getResources().getDimension(R.dimen.settings_popup_height); float popupWidth = getResources().getDimension(R.dimen.settings_popup_width); // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.setting_popup); LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.panel_settings_popup, viewGroup); // Creating the PopupWindow settingPopup = new PopupWindow(context); settingPopup.setContentView(layout); settingPopup.setWidth((int)popupWidth); settingPopup.setHeight((int)popupHeight); settingPopup.setFocusable(true); settingPopup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { hideTransparentImage(); if(player!=null){ player.getController().setSettingsBtnDrawable(false); player.getController().setAutoHide(!getTouchExploreEnabled()); } } }); // Clear the default translucent background settingPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // Displaying the popup at the specified location, + offsets. settingPopup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x-(int)popupWidth, p.y-(int)popupHeight); TextView tv_closedCaption = (TextView) layout.findViewById(R.id.tv_closedcaption); if ((langList != null) && (langList.size() > 0)) { tv_closedCaption.setBackgroundResource(R.drawable.white_rounded_selector); tv_closedCaption.setOnClickListener(new View.OnClickListener(){ public void onClick(View paramAnonymousView) { showCCFragmentPopup(); } }); }else{ tv_closedCaption.setBackgroundResource(R.drawable.grey_roundedbg); tv_closedCaption.setOnClickListener(null); } layout.findViewById(R.id.tv_video_speed).setOnClickListener(v -> showVideoSpeedFragmentPopup()); } }catch(Exception e){ logger.error(e); } }