Java Code Examples for android.support.v7.widget.ListPopupWindow#setContentWidth()
The following examples show how to use
android.support.v7.widget.ListPopupWindow#setContentWidth() .
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: ToolbarSpinner.java From FilePicker with MIT License | 6 votes |
public ToolbarSpinner(@NonNull Context context) { mListPopupWindow = new ListPopupWindow(context, null, R.attr.listPopupWindowStyle); mListPopupWindow.setModal(true); float density = context.getResources().getDisplayMetrics().density; mListPopupWindow.setContentWidth((int) (216 * density)); mListPopupWindow.setHorizontalOffset((int) (16 * density)); mListPopupWindow.setVerticalOffset((int) (-48 * density)); mListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ToolbarSpinner.this.onItemSelected(parent.getContext(), position); if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(parent, view, position, id); } } }); }
Example 2
Source File: ToolbarSpinner.java From AndroidDownload with Apache License 2.0 | 6 votes |
public ToolbarSpinner(@NonNull Context context) { mListPopupWindow = new ListPopupWindow(context, null, R.attr.listPopupWindowStyle); mListPopupWindow.setModal(true); float density = context.getResources().getDisplayMetrics().density; mListPopupWindow.setContentWidth((int) (216 * density)); mListPopupWindow.setHorizontalOffset((int) (16 * density)); mListPopupWindow.setVerticalOffset((int) (-48 * density)); mListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ToolbarSpinner.this.onItemSelected(parent.getContext(), position); if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(parent, view, position, id); } } }); }
Example 3
Source File: AlbumsSpinner.java From AlbumCameraRecorder with MIT License | 6 votes |
public AlbumsSpinner(@NonNull Context context) { // 实例化ListPopupWindow控件 mListPopupWindow = new ListPopupWindow(context, null, R.attr.listPopupWindowStyle); mListPopupWindow.setModal(true); float density = context.getResources().getDisplayMetrics().density; mListPopupWindow.setContentWidth((int) (216 * density)); mListPopupWindow.setHorizontalOffset((int) (16 * density)); mListPopupWindow.setVerticalOffset((int) (-48 * density)); // 点击事件 mListPopupWindow.setOnItemClickListener((parent, view, position, id) -> { AlbumsSpinner.this.onItemSelected(parent.getContext(), position); if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(parent, view, position, id); } }); }
Example 4
Source File: AlbumsSpinner.java From Matisse with Apache License 2.0 | 6 votes |
public AlbumsSpinner(@NonNull Context context) { mListPopupWindow = new ListPopupWindow(context, null, R.attr.listPopupWindowStyle); mListPopupWindow.setModal(true); float density = context.getResources().getDisplayMetrics().density; mListPopupWindow.setContentWidth((int) (216 * density)); mListPopupWindow.setHorizontalOffset((int) (16 * density)); mListPopupWindow.setVerticalOffset((int) (-48 * density)); mListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { AlbumsSpinner.this.onItemSelected(parent.getContext(), position); if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(parent, view, position, id); } } }); }
Example 5
Source File: Tooltip.java From wallpaperboard with Apache License 2.0 | 6 votes |
private Tooltip(Builder builder) { mBuilder = builder; mPopupWindow = new ListPopupWindow(mBuilder.mContext); mPopupWindow.setContentWidth(getMeasuredWidth(builder.mContext)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = mPopupWindow.getBackground(); if (drawable != null) { drawable.setColorFilter(ColorHelper.getAttributeColor( builder.mContext, R.attr.card_background), PorterDuff.Mode.SRC_IN); } } else { mPopupWindow.setBackgroundDrawable(new ColorDrawable( ColorHelper.getAttributeColor(builder.mContext, R.attr.card_background))); } mPopupWindow.setListSelector(new ColorDrawable(Color.TRANSPARENT)); mPopupWindow.setAnchorView(mBuilder.mTo); mPopupWindow.setForceIgnoreOutsideTouch(true); mPopupWindow.setAdapter(new TooltipAdapter(mBuilder.mContext, this)); }
Example 6
Source File: ImgSelFragment.java From youqu_master with Apache License 2.0 | 5 votes |
private void createPopupFolderList(int width, int height) { folderPopupWindow = new ListPopupWindow(getActivity()); folderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); folderPopupWindow.setAdapter(folderListAdapter); folderPopupWindow.setContentWidth(width); folderPopupWindow.setWidth(width); folderPopupWindow.setHeight(height); folderPopupWindow.setAnchorView(rlBottom); folderPopupWindow.setModal(true); folderListAdapter.setOnFloderChangeListener(new OnFolderChangeListener() { @Override public void onChange(int position, Folder folder) { folderPopupWindow.dismiss(); if (position == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); btnAlbumSelected.setText("所有图片"); } else { imageList.clear(); if (config.needCamera) imageList.add(new Image()); imageList.addAll(folder.images); imageListAdapter.notifyDataSetChanged(); btnAlbumSelected.setText(folder.name); } } }); }
Example 7
Source File: MultiImageSelectorFragment.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 创建弹出的ListView */ private void createPopupFolderList(int width, int height) { mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setHeight(height * 5/8); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (i == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText("folder_all"); mImageAdapter.setShowCamera(true); } else { Folder folder = (Folder) adapterView.getAdapter().getItem(i); if (null != folder) { Bundle args = new Bundle(); args.putString("path", folder.path); getActivity().getSupportLoaderManager().restartLoader(LOADER_CATEGORY, args, mLoaderCallback); mCategoryText.setText(folder.name); } mImageAdapter.setShowCamera(false); } mFolderAdapter.setSelectIndex(i); mFolderPopupWindow.dismiss(); // 滑动到最初始位置 mGridView.smoothScrollToPosition(0); } }); }
Example 8
Source File: MenuPopupHelper.java From floatingsearchview with Apache License 2.0 | 5 votes |
public boolean tryShow() { mPopup = new ListPopupWindow(mContext, null, mPopupStyleAttr, mPopupStyleRes); mPopup.setOnDismissListener(this); mPopup.setOnItemClickListener(this); mPopup.setAdapter(mAdapter); mPopup.setModal(true); View anchor = mAnchorView; if (anchor != null) { final boolean addGlobalListener = mTreeObserver == null; mTreeObserver = anchor.getViewTreeObserver(); // Refresh to latest if (addGlobalListener) mTreeObserver.addOnGlobalLayoutListener(this); mPopup.setAnchorView(anchor); mPopup.setDropDownGravity(mDropDownGravity); } else { return false; } if (!mHasContentWidth) { mContentWidth = measureContentWidth(); mHasContentWidth = true; } mPopup.setContentWidth(mContentWidth); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); int vertOffset = -mAnchorView.getHeight() + Util.dpToPx(4); int horizontalOffset = -mContentWidth + mAnchorView.getWidth(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { vertOffset = -mAnchorView.getHeight() - Util.dpToPx(4); horizontalOffset = -mContentWidth+mAnchorView.getWidth()-Util.dpToPx(8); } mPopup.setVerticalOffset(vertOffset); mPopup.setHorizontalOffset(horizontalOffset); mPopup.show(); mPopup.getListView().setOnKeyListener(this); return true; }
Example 9
Source File: ImgSelFragment.java From ImageSelector with Apache License 2.0 | 5 votes |
private void createPopupFolderList(int width, int height) { folderPopupWindow = new ListPopupWindow(getActivity()); folderPopupWindow.setAnimationStyle(R.style.PopupAnimBottom); folderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); folderPopupWindow.setAdapter(folderListAdapter); folderPopupWindow.setContentWidth(width); folderPopupWindow.setWidth(width); folderPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); folderPopupWindow.setAnchorView(rlBottom); folderPopupWindow.setModal(true); folderListAdapter.setOnFloderChangeListener(new OnFolderChangeListener() { @Override public void onChange(int position, Folder folder) { folderPopupWindow.dismiss(); if (position == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); btnAlbumSelected.setText(config.allImagesText); } else { imageList.clear(); if (config.needCamera) imageList.add(new Image()); imageList.addAll(folder.images); imageListAdapter.notifyDataSetChanged(); btnAlbumSelected.setText(folder.name); } } }); folderPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { setBackgroundAlpha(1.0f); } }); }
Example 10
Source File: MultiImageSelectorFragment.java From xmpp with Apache License 2.0 | 5 votes |
/** * 创建弹出的ListView */ private void createPopupFolderList(int width, int height) { mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setHeight(height * 5 / 8); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (i == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText(R.string.folder_all); mImageAdapter.setShowCamera(true); } else { Folder folder = (Folder) adapterView.getAdapter().getItem(i); if (null != folder) { Bundle args = new Bundle(); args.putString("path", folder.path); getActivity().getSupportLoaderManager().restartLoader(LOADER_CATEGORY, args, mLoaderCallback); mCategoryText.setText(folder.name); } mImageAdapter.setShowCamera(false); } mFolderAdapter.setSelectIndex(i); mFolderPopupWindow.dismiss(); // 滑动到最初始位置 mGridView.smoothScrollToPosition(0); } }); }
Example 11
Source File: Popup.java From wallpaperboard with Apache License 2.0 | 5 votes |
private Popup(Builder builder) { mPopupWindow = new ListPopupWindow(builder.mContext); mAdapter = new PopupAdapter(builder.mContext, builder.mItems); int width = getMeasuredWidth(builder.mContext); mPopupWindow.setContentWidth(width); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = mPopupWindow.getBackground(); if (drawable != null) { drawable.setColorFilter(ColorHelper.getAttributeColor( builder.mContext, R.attr.card_background), PorterDuff.Mode.SRC_IN); } } else { mPopupWindow.setBackgroundDrawable(new ColorDrawable( ColorHelper.getAttributeColor(builder.mContext, R.attr.card_background))); } mPopupWindow.setAnchorView(builder.mTo); mPopupWindow.setAdapter(mAdapter); mPopupWindow.setOnItemClickListener((adapterView, view, i, l) -> { if (builder.mCallback != null) { builder.mCallback.onClick(this, i); return; } mPopupWindow.dismiss(); }); }
Example 12
Source File: PictureGridActivity.java From PicturePicker with Apache License 2.0 | 4 votes |
/** * 初始化展示文件夹列表的popupWindow */ private ListPopupWindow initFolderListPopupWindow() { listPopupWindow = new ListPopupWindow(this); listPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); //ListPopupWindow总会相对于这个View 锚点 listPopupWindow.setAnchorView(llFootBar); listPopupWindow.setDropDownGravity(Gravity.BOTTOM); //是否为模态,影响返回键的处理 listPopupWindow.setModal(true); listPopupWindow.setContentWidth(ListPopupWindow.MATCH_PARENT); listPopupWindow.setWidth(ListPopupWindow.MATCH_PARENT); folderListAdapter = new PopupFolderListAdapter(this, pictureFolderList); listPopupWindow.setAdapter(folderListAdapter); listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { Utils.setActivityBackgroundAlpha(PictureGridActivity.this, 1.0f); } }); listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PictureFolder pictureFolder = pictureFolderList.get(position); if (!TextUtils.equals(pictureFolder.folderAbsPath, folderListAdapter.getCurrentSelectFolderPath())) { folderListAdapter.notifyDataSetChanged(pictureFolder.folderAbsPath); //更新底部文件夹名称 setBtnImgFolderText(pictureFolder.folderName); //更新显示的图片 notifyPictureGrid(pictureFolder.pictureItemList); } listPopupWindow.dismiss(); } }); return listPopupWindow; }
Example 13
Source File: MultiImageSelectorFragment.java From monolog-android with MIT License | 4 votes |
/** * 创建弹出的ListView */ private void createPopupFolderList() { Point point = ScreenUtils.getScreenSize(getActivity()); int width = point.x; int height = (int) (point.y * (4.5f/8.0f)); mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setWidth(width); mFolderPopupWindow.setHeight(height); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mFolderAdapter.setSelectIndex(i); final int index = i; final AdapterView v = adapterView; new Handler().postDelayed(new Runnable() { @Override public void run() { mFolderPopupWindow.dismiss(); if (index == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText(R.string.folder_all); if (mIsShowCamera) { mImageAdapter.setShowCamera(true); } else { mImageAdapter.setShowCamera(false); } } else { Folder folder = (Folder) v.getAdapter().getItem(index); if (null != folder) { mImageAdapter.setData(folder.images); mCategoryText.setText(folder.name); // 设定默认选择 if (resultList != null && resultList.size() > 0) { mImageAdapter.setDefaultSelected(resultList); } } mImageAdapter.setShowCamera(false); } // 滑动到最初始位置 mGridView.smoothScrollToPosition(0); } }, 100); } }); }
Example 14
Source File: MultiImageSelectorFragment.java From ImageChoose with MIT License | 4 votes |
/** * 创建弹出的ListView */ private void createPopupFolderList(int width, int height) { mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setWidth(width); mFolderPopupWindow.setHeight(height * 5 / 8); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mFolderAdapter.setSelectIndex(i); final int index = i; final AdapterView v = adapterView; new Handler().postDelayed(new Runnable() { @Override public void run() { mFolderPopupWindow.dismiss(); if (index == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText(R.string.folder_all); if (mIsShowCamera) { mImageAdapter.setShowCamera(true); if(mIsShowText && mode==MODE_MULTI){//多选的时候才显示文本 mImageAdapter.setShowTxt(true); }else{ mImageAdapter.setShowTxt(false); } }else { mImageAdapter.setShowCamera(false); mImageAdapter.setShowTxt(false); } } else { Folder folder = (Folder) v.getAdapter().getItem(index); if (null != folder) { mImageAdapter.setData(folder.images); mCategoryText.setText(folder.name); // 设定默认选择 if (resultList != null && resultList.size() > 0) { mImageAdapter.setDefaultSelected(resultList); } } mImageAdapter.setShowCamera(false); mImageAdapter.setShowTxt(false); } // 滑动到最初始位置 mGridView.smoothScrollToPosition(0); } }, 100); } }); }
Example 15
Source File: MultiImageSelectorFragment.java From MultiImageSelector with MIT License | 4 votes |
/** * Create popup ListView */ private void createPopupFolderList() { Point point = ScreenUtils.getScreenSize(getActivity()); int width = point.x; int height = (int) (point.y * (4.5f/8.0f)); mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setWidth(width); mFolderPopupWindow.setHeight(height); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mFolderAdapter.setSelectIndex(i); final int index = i; final AdapterView v = adapterView; new Handler().postDelayed(new Runnable() { @Override public void run() { mFolderPopupWindow.dismiss(); if (index == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText(R.string.mis_folder_all); if (showCamera()) { mImageAdapter.setShowCamera(true); } else { mImageAdapter.setShowCamera(false); } } else { Folder folder = (Folder) v.getAdapter().getItem(index); if (null != folder) { mImageAdapter.setData(folder.images); mCategoryText.setText(folder.name); if (resultList != null && resultList.size() > 0) { mImageAdapter.setDefaultSelected(resultList); } } mImageAdapter.setShowCamera(false); } mGridView.smoothScrollToPosition(0); } }, 100); } }); }
Example 16
Source File: MultiImageSelectorFragment.java From HeartBeat with Apache License 2.0 | 4 votes |
/** * 创建弹出的ListView */ private void createPopupFolderList() { Point point = ScreenUtils.getScreenSize(getActivity()); int width = point.x; int height = (int) (point.y * (4.5f/8.0f)); mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setWidth(width); mFolderPopupWindow.setHeight(height); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mFolderAdapter.setSelectIndex(i); final int index = i; final AdapterView v = adapterView; new Handler().postDelayed(new Runnable() { @Override public void run() { mFolderPopupWindow.dismiss(); if (index == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText(R.string.folder_all); if (mIsShowCamera) { mImageAdapter.setShowCamera(true); } else { mImageAdapter.setShowCamera(false); } } else { Folder folder = (Folder) v.getAdapter().getItem(index); if (null != folder) { mImageAdapter.setData(folder.images); mCategoryText.setText(folder.name); // 设定默认选择 if (resultList != null && resultList.size() > 0) { mImageAdapter.setDefaultSelected(resultList); } } mImageAdapter.setShowCamera(false); } // 滑动到最初始位置 mGridView.smoothScrollToPosition(0); } }, 100); } }); }
Example 17
Source File: MultiImageSelectorFragment.java From Luban-Circle-Demo with Apache License 2.0 | votes |
/** * 创建弹出的ListView */ private void createPopupFolderList() { Point point = ScreenUtils.getScreenSize(getActivity()); int width = point.x; int height = (int) (point.y * (4.5f/8.0f)); mFolderPopupWindow = new ListPopupWindow(getActivity()); mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); mFolderPopupWindow.setAdapter(mFolderAdapter); mFolderPopupWindow.setContentWidth(width); mFolderPopupWindow.setWidth(width); mFolderPopupWindow.setHeight(height); mFolderPopupWindow.setAnchorView(mPopupAnchorView); mFolderPopupWindow.setModal(true); mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mFolderAdapter.setSelectIndex(i); final int index = i; final AdapterView v = adapterView; new Handler().postDelayed(new Runnable() { @Override public void run() { mFolderPopupWindow.dismiss(); if (index == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); mCategoryText.setText(R.string.folder_all); if (mIsShowCamera) { mImageAdapter.setShowCamera(true); } else { mImageAdapter.setShowCamera(false); } } else { Folder folder = (Folder) v.getAdapter().getItem(index); if (null != folder) { mImageAdapter.setData(folder.images); mCategoryText.setText(folder.name); // 设定默认选择 if (resultList != null && resultList.size() > 0) { mImageAdapter.setDefaultSelected(resultList); } } mImageAdapter.setShowCamera(false); } // 滑动到最初始位置 mGridView.smoothScrollToPosition(0); } }, 100); } }); }