本文整理匯總了Java中android.widget.ListPopupWindow.setWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java ListPopupWindow.setWidth方法的具體用法?Java ListPopupWindow.setWidth怎麽用?Java ListPopupWindow.setWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListPopupWindow
的用法示例。
在下文中一共展示了ListPopupWindow.setWidth方法的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: 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();
}
});
}
示例3: 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);
}
示例4: 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);
}
示例5: 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();
}
});
}
示例6: createPopWindow
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
private void createPopWindow(){
popupWindow = new ListPopupWindow(getContext());
popupAdapter = new SelectorAdapter();
popupWindow.setAnchorView(parent.getChildAt(0));
popupWindow.setAdapter(popupAdapter);
popupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
//獲取焦點
popupWindow.setModal(true);
popupWindow.setOnItemClickListener(this);
popupWindow.setOnDismissListener(this);
}
示例7: createPopupFolderList
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
/** 創建彈出的ListView */
private void createPopupFolderList(int width, int height) {
mFolderPopupWindow = new ListPopupWindow(this);
mFolderPopupWindow.setBackgroundDrawable(null);
mFolderPopupWindow.setAdapter(mImageFolderAdapter);
mFolderPopupWindow.setContentWidth(width);
mFolderPopupWindow.setWidth(width); //如果不設置,就是 AnchorView 的寬度
mFolderPopupWindow.setHeight(height * 5 / 8);
mFolderPopupWindow.setAnchorView(mFooterBar); //ListPopupWindow總會相對於這個View
mFolderPopupWindow.setModal(false); //是否為模態,影響返回鍵的處理
mFolderPopupWindow.setAnimationStyle(R.style.popupwindow_anim_style);
mFolderPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
backgroundAlpha(1.0f);
}
});
mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
mImageFolderAdapter.setSelectIndex(position);
imagePicker.setCurrentImageFolderPosition(position);
mFolderPopupWindow.dismiss();
ImageFolder imageFolder = (ImageFolder) adapterView.getAdapter().getItem(position);
if (null != imageFolder) {
mImageGridAdapter.refreshData(imageFolder.images);
mBtnDir.setText(imageFolder.name);
}
gv_photo_list.smoothScrollToPosition(0);//滑動到頂部
}
});
}
示例8: initPopupWindow
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
private void initPopupWindow() {
popupWindow = new ListPopupWindow(mContext) {
@Override
public void show() {
super.show();
mRightImageTopView.setClickable(true);
mRightIv.startAnimation(mAnimation);
}
@Override
public void dismiss() {
super.dismiss();
}
};
popupWindow.setOnItemClickListener(this);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
popupWindow.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setAnchorView(editText);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
popupWindowHideTime = System.currentTimeMillis();
mRightIv.startAnimation(mResetAnimation);
}
});
}
示例9: createPopupFolderList
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
private void createPopupFolderList() {
mFolderPopupWindow = new ListPopupWindow(this);
mFolderPopupWindow.setAdapter(mFolderAdapter);
mFolderPopupWindow.setContentWidth(ListPopupWindow.MATCH_PARENT);
mFolderPopupWindow.setWidth(ListPopupWindow.MATCH_PARENT);
mFolderPopupWindow.setHeight(ListPopupWindow.MATCH_PARENT);
mFolderPopupWindow.setAnchorView(toolbar);
mFolderPopupWindow.setModal(true);
mFolderPopupWindow.setAnimationStyle(R.style.popwindow_anim_style);
mFolderPopupWindow.setOnItemClickListener(this);
}
示例10: onLongClick
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
@Override public boolean onLongClick(View v) {
String[] versions = { "Camera", "Laptop", "Watch", "Smartphone",
"Television" };
final ListPopupWindow listPopupWindow = new ListPopupWindow(
getActivity());
listPopupWindow.setAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_dropdown_item_1line, versions));
listPopupWindow.setAnchorView(mListPopupButton);
listPopupWindow.setWidth(300);
listPopupWindow.setHeight(400);
listPopupWindow.setModal(true);
listPopupWindow.show();
return false;
}
示例11: showAlternates
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
private void showAlternates(RecipientChip currentChip, ListPopupWindow alternatesPopup,
int width, Context context) {
int line = getLayout().getLineForOffset(getChipStart(currentChip));
int bottom;
if (line == getLineCount() -1) {
bottom = 0;
} else {
bottom = -(int) ((mChipHeight + (2 * mLineSpacingExtra)) * (Math.abs(getLineCount() - 1
- line)));
}
// Align the alternates popup with the left side of the View,
// regardless of the position of the chip tapped.
alternatesPopup.setWidth(width);
alternatesPopup.setAnchorView(this);
alternatesPopup.setVerticalOffset(bottom);
alternatesPopup.setAdapter(createAlternatesAdapter(currentChip));
alternatesPopup.setOnItemClickListener(mAlternatesListener);
// Clear the checked item.
mCheckedItem = -1;
alternatesPopup.show();
ListView listView = alternatesPopup.getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
// Checked item would be -1 if the adapter has not
// loaded the view that should be checked yet. The
// variable will be set correctly when onCheckedItemChanged
// is called in a separate thread.
if (mCheckedItem != -1) {
listView.setItemChecked(mCheckedItem, true);
mCheckedItem = -1;
}
}
示例12: StripLayoutHelper
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
/**
* Creates an instance of the {@link StripLayoutHelper}.
* @param context The current Android {@link Context}.
* @param updateHost The parent {@link LayoutUpdateHost}.
* @param renderHost The {@link LayoutRenderHost}.
* @param incognito Whether or not this tab strip is incognito.
*/
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
LayoutRenderHost renderHost, boolean incognito) {
mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;
mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
mMinTabWidth = MIN_TAB_WIDTH_DP;
mMaxTabWidth = MAX_TAB_WIDTH_DP;
mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
mUpdateHost = updateHost;
mRenderHost = renderHost;
mNewTabButton =
new CompositorButton(context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP);
mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
R.drawable.btn_tabstrip_new_tab_pressed,
R.drawable.btn_tabstrip_new_incognito_tab_normal,
R.drawable.btn_tabstrip_new_incognito_tab_pressed);
mNewTabButton.setIncognito(incognito);
mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
Resources res = context.getResources();
mNewTabButton.setAccessibilityDescription(
res.getString(R.string.accessibility_toolbar_btn_new_tab),
res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
mContext = context;
mIncognito = incognito;
mBrightness = 1.f;
// Create tab menu
mTabMenu = new ListPopupWindow(mContext);
mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
new String[] {
mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
: R.string.menu_close_all_incognito_tabs)}));
mTabMenu.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mTabMenu.dismiss();
if (position == ID_CLOSE_ALL_TABS) {
mModel.closeAllTabs(false, false);
}
}
});
int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
mTabMenu.setWidth(menuWidth);
mTabMenu.setModal(true);
int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
mIsFirstLayoutPass = true;
}
示例13: initFromAttributes
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
private void initFromAttributes(Context context, AttributeSet attrs, int defStyleAttr) {
final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.EditSpinner, defStyleAttr, 0);
mPopup = new ListPopupWindow(context, attrs);
mPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW);
Drawable selector = a.getDrawable(R.styleable.EditSpinner_dropDownSelector);
if (selector != null) {
mPopup.setListSelector(selector);
}
int dropDownAnimStyleResId = a.getResourceId(R.styleable.EditSpinner_dropDownAnimStyle, -1);
if (dropDownAnimStyleResId > 0) {
setDropDownAnimationStyle(dropDownAnimStyleResId);
}
mDropDownDrawable = a.getDrawable(R.styleable.EditSpinner_dropDownDrawable);
int dropDownDrawableSpacing = a.getDimensionPixelOffset(R.styleable.EditSpinner_dropDownDrawableSpacing, 0);
if (mDropDownDrawable != null) {
int dropDownDrawableWidth = a.getDimensionPixelOffset(R.styleable.EditSpinner_dropDownDrawableWidth, -1);
int dropDownDrawableHeight = a.getDimensionPixelOffset(R.styleable.EditSpinner_dropDownDrawableHeight, -1);
setDropDownDrawable(mDropDownDrawable, dropDownDrawableWidth, dropDownDrawableHeight);
setDropDownDrawableSpacing(dropDownDrawableSpacing);
}
// Get the anchor's id now, but the view won't be ready, so wait to actually get the
// view and store it in mDropDownAnchorView lazily in getDropDownAnchorView later.
// Defaults to NO_ID, in which case the getDropDownAnchorView method will simply return
// this TextView, as a default anchoring point.
mDropDownAnchorId = a.getResourceId(R.styleable.EditSpinner_dropDownAnchor,
View.NO_ID);
// For dropdown width, the developer can specify a specific width, or MATCH_PARENT
// (for full screen width) or WRAP_CONTENT (to match the width of the anchored view).
mPopup.setWidth(a.getLayoutDimension(R.styleable.EditSpinner_dropDownWidth,
ViewGroup.LayoutParams.WRAP_CONTENT));
mPopup.setHeight(a.getLayoutDimension(R.styleable.EditSpinner_dropDownHeight,
ViewGroup.LayoutParams.WRAP_CONTENT));
mPopup.setOnItemClickListener(new DropDownItemClickListener());
mPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
mLastDismissTime = SystemClock.elapsedRealtime();
if (mOnDismissListener != null) {
mOnDismissListener.onDismiss();
}
}
});
a.recycle();
mIsEditable = getKeyListener() != null;
setFocusable(true);
addTextChangedListener(new MyWatcher());
}
示例14: StripLayoutHelper
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
/**
* Creates an instance of the {@link StripLayoutHelper}.
* @param context The current Android {@link Context}.
* @param updateHost The parent {@link LayoutUpdateHost}.
* @param renderHost The {@link LayoutRenderHost}.
* @param incognito Whether or not this tab strip is incognito.
*/
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
LayoutRenderHost renderHost, boolean incognito) {
mTabStackWidth = TAB_STACK_WIDTH_DP;
mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;
if (LocalizationUtils.isLayoutRtl()) {
// In rtl let the tab nest closer to the new tab button.
mNewTabButtonWidth -= mTabOverlapWidth / 2;
}
mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
mMinTabWidth = MIN_TAB_WIDTH_DP;
mMaxTabWidth = MAX_TAB_WIDTH_DP;
mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
mUpdateHost = updateHost;
mRenderHost = renderHost;
mNewTabButton =
new CompositorButton(context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP);
mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
R.drawable.btn_tabstrip_new_tab_pressed,
R.drawable.btn_tabstrip_new_incognito_tab_normal,
R.drawable.btn_tabstrip_new_incognito_tab_pressed);
mNewTabButton.setIncognito(incognito);
mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
Resources res = context.getResources();
mNewTabButton.setAccessibilityDescription(
res.getString(R.string.accessibility_toolbar_btn_new_tab),
res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
mContext = context;
mIncognito = incognito;
mBrightness = 1.f;
// Create tab menu
mTabMenu = new ListPopupWindow(mContext);
mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.eb_popup_item,
new String[] {
mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
: R.string.menu_close_all_incognito_tabs)}));
mTabMenu.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mTabMenu.dismiss();
if (position == ID_CLOSE_ALL_TABS) {
mModel.closeAllTabs(false, false);
}
}
});
int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
mTabMenu.setWidth(menuWidth);
mTabMenu.setModal(true);
}
示例15: createPopupFolderList
import android.widget.ListPopupWindow; //導入方法依賴的package包/類
private void createPopupFolderList(int width, int height) {
folderPopupWindow = new ListPopupWindow(getActivity());
folderPopupWindow.setBackgroundDrawable(null);
folderPopupWindow.setAdapter(folderAdapter);
folderPopupWindow.setContentWidth(width);
folderPopupWindow.setWidth(width);
folderPopupWindow.setHeight(height * 5 / 8);
folderPopupWindow.setAnchorView(popupAnchorView);
folderPopupWindow.setModal(true);
folderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
folderAdapter.setSelectIndex(i);
final int index = i;
final AdapterView v = adapterView;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
folderPopupWindow.dismiss();
if (index == 0) {
getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
category_button.setText(R.string.all_folder);
callback.onChangeAlbum(context.getResources().getString(R.string.all_folder));
if (imageConfig.isShowCamera()) {
imageAdapter.setShowCamera(true);
} else {
imageAdapter.setShowCamera(false);
}
}
else {
Folder folder = (Folder) v.getAdapter().getItem(index);
if (null != folder) {
imageList.clear();
imageList.addAll(folder.images);
imageAdapter.notifyDataSetChanged();
category_button.setText(folder.name);
callback.onChangeAlbum(folder.name);
if (resultList != null && resultList.size() > 0) {
imageAdapter.setDefaultSelected(resultList);
}
}
imageAdapter.setShowCamera(false);
}
grid_image.smoothScrollToPosition(0);
}
}, 100);
}
});
}