List of usage examples for android.widget ListPopupWindow getListView
@Override
public @Nullable ListView getListView()
From source file:com.duy.pascal.ui.editor.view.CodeSuggestsEditText.java
private void performCompletion(View selectedView, int position, long id) { if (isPopupShowing()) { Object selectedItem;// w w w . j a v a 2s . c om if (position < 0) { selectedItem = mPopup.getSelectedItem(); } else { selectedItem = mAdapter.getItem(position); } if (selectedItem == null) { DLog.w(TAG, "performCompletion: no selected item"); return; } mBlockCompletion = true; try { replaceText(convertSelectionToString(selectedItem)); } catch (Exception ignored) { //something wrong when start app ignored.printStackTrace(); } mBlockCompletion = false; if (mItemClickListener != null) { final ListPopupWindow list = mPopup; if (selectedView == null || position < 0) { selectedView = list.getSelectedView(); position = list.getSelectedItemPosition(); id = list.getSelectedItemId(); } mItemClickListener.onItemClick(list.getListView(), selectedView, position, id); } } if (mDropDownDismissedOnCompletion) { dismissDropDown(); } }
From source file:android.support.v7ox.widget.ActivityChooserView.java
/** * Shows the popup no matter if it was already showing. * * @param maxActivityCount The max number of activities to display. *//*from w w w . j av a 2s . co m*/ private void showPopupUnchecked(int maxActivityCount) { if (mAdapter.getDataModel() == null) { throw new IllegalStateException("No data model. Did you call #setDataModel?"); } getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener); final boolean defaultActivityButtonShown = mDefaultActivityButton.getVisibility() == VISIBLE; final int activityCount = mAdapter.getActivityCount(); final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0; if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED && activityCount > maxActivityCount + maxActivityCountOffset) { mAdapter.setShowFooterView(true); mAdapter.setMaxActivityCount(maxActivityCount - 1); } else { mAdapter.setShowFooterView(false); mAdapter.setMaxActivityCount(maxActivityCount); } ListPopupWindow popupWindow = getListPopupWindow(); if (!popupWindow.isShowing()) { if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) { mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown); } else { mAdapter.setShowDefaultActivity(false, false); } final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth); popupWindow.setContentWidth(contentWidth); popupWindow.show(); if (mProvider != null) { mProvider.subUiVisibilityChanged(true); } popupWindow.getListView().setContentDescription( getContext().getString(R.string.abc_activitychooserview_choose_application)); } }