本文整理汇总了Java中android.widget.ListPopupWindow类的典型用法代码示例。如果您正苦于以下问题:Java ListPopupWindow类的具体用法?Java ListPopupWindow怎么用?Java ListPopupWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListPopupWindow类属于android.widget包,在下文中一共展示了ListPopupWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showAddress
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void showAddress(final DrawableRecipientChip currentChip, final ListPopupWindow popup,
int width) {
if (!mAttachedToWindow) {
return;
}
int line = getLayout().getLineForOffset(getChipStart(currentChip));
int bottom = calculateOffsetFromBottom(line);
// Align the alternates popup with the left side of the View,
// regardless of the position of the chip tapped.
popup.setWidth(width);
popup.setAnchorView(this);
popup.setVerticalOffset(bottom);
popup.setAdapter(createSingleAddressAdapter(currentChip));
popup.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
unselectChip(currentChip);
popup.dismiss();
}
});
popup.show();
ListView listView = popup.getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setItemChecked(0, true);
}
示例2: initView
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void initView(Context context) {
// TODO: validator?
alternatesPopup = new ListPopupWindow(context);
alternatesAdapter = new AlternateRecipientAdapter(context, this);
alternatesPopup.setAdapter(alternatesAdapter);
// don't allow duplicates, based on equality of recipient objects, which is e-mail addresses
allowDuplicates(false);
// if a token is completed, pick an entry based on best guess.
// Note that we override performCompletion, so this doesn't actually do anything
performBestGuess(true);
adapter = new RecipientAdapter(context);
setAdapter(adapter);
setLongClickable(true);
}
示例3: showDownloadTypeChooser
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void showDownloadTypeChooser(View anchor) {
//noinspection ConstantConditions
final ListPopupWindow popupWindow = new ListPopupWindow(getContext());
SimpleDropDownAdapter<Integer> adapter = new SimpleDropDownAdapter<>(
getContext(), mDownloadTypes, mModel.downloadType);
popupWindow.setAnchorView(anchor);
popupWindow.setAdapter(adapter);
popupWindow.setContentWidth(adapter.measureContentWidth());
popupWindow.setOnItemClickListener((parent, view, position, id) -> {
popupWindow.dismiss();
// Update the view
mModel.downloadType = mDownloadTypes.get(position);
mBinding.downloadCommands
.from(mDownloadCommands.get(mModel.downloadType))
.update();
mBinding.setModel(mModel);
mBinding.executePendingBindings();
});
popupWindow.setModal(true);
popupWindow.show();
}
示例4: initPopup
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void initPopup() {
View menuItemView = getActivity().findViewById(R.id.pick_category);
listPopupWindow = new ListPopupWindow(getActivity());
listPopupWindow.setAnchorView(menuItemView);
listPopupWindow.setModal(true);
listPopupWindow.setWidth(categoryListWidth);
listPopupWindow.setHeight(ListPopupWindow.WRAP_CONTENT);
listPopupWindow
.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (ourListAdapter != null)
ourListAdapter.notifyDataSetChanged();
}
});
}
示例5: showDropDown
import android.widget.ListPopupWindow; //导入依赖的package包/类
public void showDropDown() {
if (mPopup.getAnchorView() == null) {
if (mDropDownAnchorId != View.NO_ID) {
mPopup.setAnchorView(getRootView().findViewById(mDropDownAnchorId));
} else {
mPopup.setAnchorView(this);
}
}
if (!isPopupShowing()) {
// Make sure the list does not obscure the IME when shown for the first time.
mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
}
requestFocus();
mPopup.show();
mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
if (mOnShowListener != null) {
mOnShowListener.onShow();
}
}
示例6: getVerticalOffset
import android.widget.ListPopupWindow; //导入依赖的package包/类
public static int getVerticalOffset(ListPopupWindow popupWindow, View anchorView, int position, int contentHeight) {
final int shadow = calculateVerticalShadow(popupWindow);
int offset = -shadow;
if ((position & PopupGravity.BOTTOM) == PopupGravity.BOTTOM || (position & PopupDirection.DOWN) == PopupDirection.DOWN) {
offset += 0;
}
if ((position & PopupGravity.TOP) == PopupGravity.TOP) {
offset += -anchorView.getHeight();
}
if ((position & PopupGravity.CENTER_VERTICAL) == PopupGravity.CENTER_VERTICAL || (position & PopupGravity.CENTER) == PopupGravity.CENTER) {
offset += -anchorView.getHeight() / 2;
}
if ((position & PopupDirection.UP) == PopupDirection.UP) {
offset += -contentHeight - anchorView.getHeight() - (2 * shadow);
}
return offset;
}
示例7: getHorizontalOffset
import android.widget.ListPopupWindow; //导入依赖的package包/类
public static int getHorizontalOffset(ListPopupWindow popupWindow, View anchorView, int position, int contentWidth) {
final int shadow = calculateHorizontalShadow(popupWindow);
int offset = -shadow;
if ((position & PopupGravity.LEFT) == PopupGravity.LEFT) {
offset += 0;
}
if ((position & PopupGravity.RIGHT) == PopupGravity.RIGHT) {
offset += anchorView.getWidth();
}
if ((position & PopupGravity.CENTER_HORIZONTAL) == PopupGravity.CENTER_HORIZONTAL || (position & PopupGravity.CENTER) == PopupGravity.CENTER) {
offset += anchorView.getWidth() / 2;
}
if ((position & PopupDirection.LEFT) == PopupDirection.LEFT) {
offset += -contentWidth;
}
return offset;
}
示例8: setupList
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void setupList() {
mPopup = new ListPopupWindow(mContext);
mPopup.setAdapter(mAdapter);
mPopup.setAnchorView(mAnchorView);
mContentWidth = ListUtils.measureListContentWidth(mAdapter, mContext);
mContentHeight = ListUtils.measureListContentHeight(mAdapter, mContext);
mPopup.setContentWidth(mContentWidth);
mPopup.setModal(mIsModal);
mPopup.setOnDismissListener(mOnDismissListener);
mPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (mOnPopupListItemListener != null)
mOnPopupListItemListener.onPopupListItemClicked(new PopupItem(mAdapter.getItem(position)));
mPopup.dismiss();
}
});
if (mAnimationStyle != -1) {
mPopup.setAnimationStyle(mAnimationStyle);
}
}
示例9: disableHideOnOutsideTap
import android.widget.ListPopupWindow; //导入依赖的package包/类
/**
* Disable hiding on outside tap so that tapping on a text input field associated with the popup
* will not hide the popup.
*/
public void disableHideOnOutsideTap() {
// HACK: The ListPopupWindow's mPopup automatically dismisses on an outside tap. There's
// no way to override it or prevent it, except reaching into ListPopupWindow's hidden
// API. This allows the C++ controller to completely control showing/hiding the popup.
// See http://crbug.com/400601
try {
Method setForceIgnoreOutsideTouch = ListPopupWindow.class.getMethod(
"setForceIgnoreOutsideTouch", new Class[] { boolean.class });
setForceIgnoreOutsideTouch.invoke(this, new Object[] { true });
} catch (Exception e) {
Log.e("AutofillPopup",
"ListPopupWindow.setForceIgnoreOutsideTouch not found",
e);
}
}
示例10: init
import android.widget.ListPopupWindow; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void init()
{
super.init();
addAttrDescAN(new AttrDescView_widget_AutoCompleteTextView_completionHint(this));
addAttrDescAN(new AttrDescView_widget_AutoCompleteTextView_completionHintView(this));
addAttrDescAN(new AttrDescReflecMethodInt(this, "completionThreshold", "setThreshold", 2));
addAttrDescAN(new AttrDescReflecMethodId(this, "dropDownAnchor", -1));
addAttrDescAN(new AttrDescReflecMethodDimensionWithNameInt(this, "dropDownHeight", (float) ViewGroup.LayoutParams.WRAP_CONTENT));
addAttrDescAN(new AttrDescReflecMethodDimensionIntFloor(this, "dropDownHorizontalOffset", 0.0f));
addAttrDescAN(new AttrDescReflecFieldMethodDrawable(this, "dropDownSelector", "mPopup", ListPopupWindow.class, "setListSelector", null)); // Hay un background por defecto de Android en ListPopupWindow aunque parece que por defecto se pone un null si no hay atributo
addAttrDescAN(new AttrDescReflecMethodDimensionIntFloor(this, "dropDownVerticalOffset", 0.0f));
addAttrDescAN(new AttrDescReflecMethodDimensionWithNameInt(this, "dropDownWidth", (float) ViewGroup.LayoutParams.WRAP_CONTENT));
addAttrDescAN(new AttrDescReflecMethodDrawable(this, "popupBackground", "setDropDownBackgroundDrawable", "@null"));
}
示例11: onClick
import android.widget.ListPopupWindow; //导入依赖的package包/类
@Override
public void onClick(View v) {
//TODO: refactor/redesign
final int regionId = v.getId();
final List<Integer> listsRegionsId = mRegionsDB.getAllThemesIds();
final ListPopupWindow listThemesPopupWindow = new ListPopupWindow(mActivity);
listThemesPopupWindow.setAdapter(new ArrayAdapter<String>(mActivity, R.layout.list_item_theme, mRegionsDB.getAllThemesNames()));
listThemesPopupWindow.setModal(true);
listThemesPopupWindow.setAnchorView(v);
OnItemClickListener itemClickListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
changeTheme(regionId, listsRegionsId.get(position));
listThemesPopupWindow.dismiss();
((EditorActivity)mActivity).refreshTable();
}
};
listThemesPopupWindow.setOnItemClickListener(itemClickListener);
listThemesPopupWindow.show();
}
示例12: showAddress
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void showAddress(final RecipientChip currentChip, final ListPopupWindow popup,
int width, Context context) {
int line = getLayout().getLineForOffset(getChipStart(currentChip));
int bottom = calculateOffsetFromBottom(line);
// Align the alternates popup with the left side of the View,
// regardless of the position of the chip tapped.
popup.setWidth(width);
popup.setAnchorView(this);
popup.setVerticalOffset(bottom);
popup.setAdapter(createSingleAddressAdapter(currentChip));
popup.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
unselectChip(currentChip);
popup.dismiss();
}
});
popup.show();
ListView listView = popup.getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setItemChecked(0, true);
}
示例13: showAddress
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void showAddress(final DrawableRecipientChip currentChip,final ListPopupWindow popup,final int width)
{
if(!mAttachedToWindow)
return;
final int line=getLayout().getLineForOffset(getChipStart(currentChip));
final int bottom=calculateOffsetFromBottom(line);
// Align the alternates popup with the left side of the View,
// regardless of the position of the chip tapped.
popup.setWidth(width);
popup.setAnchorView(this);
popup.setVerticalOffset(bottom);
popup.setAdapter(createSingleAddressAdapter(currentChip));
popup.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(final AdapterView<?> parent,final View view,final int position,final long id)
{
unselectChip(currentChip);
popup.dismiss();
}
});
popup.show();
final ListView listView=popup.getListView();
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
listView.setItemChecked(0,true);
}
示例14: showListPopupWindow
import android.widget.ListPopupWindow; //导入依赖的package包/类
protected void showListPopupWindow() {
ArrayAdapter<String> adapter=
new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
ITEMS);
final ListPopupWindow popup=new ListPopupWindow(this);
popup.setAnchorView(popupAnchor);
popup.setAdapter(adapter);
popup.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
popup.dismiss();
}
});
popup.show();
}
示例15: initPopup
import android.widget.ListPopupWindow; //导入依赖的package包/类
private void initPopup() {
View menuItemView = getActivity().findViewById(R.id.pick_category);
listPopupWindow = new ListPopupWindow(getActivity());
listPopupWindow.setAnchorView(menuItemView);
listPopupWindow.setModal(true);
listPopupWindow.setWidth(categoryListWidth);
listPopupWindow.setHeight(ListPopupWindow.WRAP_CONTENT);
listPopupWindow
.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (listAdapter != null)
listAdapter.notifyDataSetChanged();
}
});
}