android.widget.AbsListView Java Examples
The following examples show how to use
android.widget.AbsListView.
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: DialogRootView.java From AndroidMaterialDialog with Apache License 2.0 | 6 votes |
/** * Searches for the list view, which is contained by the dialog, in order to register a scroll * listener. * * @param view The view, which should be searched, as an instance of the class {@link ViewGroup}. * The view may not be null */ private boolean findListOrRecyclerView(@NonNull final View view) { if (view instanceof AbsListView) { this.listView = (AbsListView) view; this.listView.setOnScrollListener(createListViewScrollListener()); return true; } else if (view instanceof RecyclerView) { this.recyclerView = (RecyclerView) view; this.recyclerView.addOnScrollListener(createRecyclerViewScrollListener()); return true; } else if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { if (findListOrRecyclerView(viewGroup.getChildAt(i))) { return true; } } } return false; }
Example #2
Source File: PullToZoomListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override public void onScroll(AbsListView paramAbsListView, int paramInt1, int paramInt2, int paramInt3) { Log.d(TAG, "onScroll"); if (mHeaderView != null && !isHideHeader && isEnableZoom) { float f = mHeaderHeight - mHeaderContainer.getBottom(); Log.d(TAG, "f = " + f); if (isParallax) { if ((f > 0.0F) && (f < mHeaderHeight)) { int i = (int) (0.65D * f); mHeaderContainer.scrollTo(0, -i); } else if (mHeaderContainer.getScrollY() != 0) { mHeaderContainer.scrollTo(0, 0); } } } if (mOnScrollListener != null) { mOnScrollListener.onScroll(paramAbsListView, paramInt1, paramInt2, paramInt3); } }
Example #3
Source File: MetroViewBorderHandler.java From TVSample with Apache License 2.0 | 6 votes |
@Override public void onFocusChanged(View oldFocus, View newFocus) { try { if (newFocus instanceof AbsListView) { return; } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setInterpolator(new DecelerateInterpolator(1)); animatorSet.setDuration(mDurationTraslate); animatorSet.playTogether(mAnimatorList); for (Animator.AnimatorListener listener : mAnimatorListener) { animatorSet.addListener(listener); } mAnimatorSet = animatorSet; if (oldFocus == null) { animatorSet.setDuration(0); mTarget.setVisibility(View.VISIBLE); } animatorSet.start(); } catch (Exception ex) { ex.printStackTrace(); } }
Example #4
Source File: StickHeaderViewPager.java From StickyHeaderViewPager with Apache License 2.0 | 6 votes |
private int getScrollY(AbsListView view) { View child = view.getChildAt(0); if (child == null) { return 0; } int firstVisiblePosition = view.getFirstVisiblePosition(); int top = child.getTop(); int headerHeight = 0; if (firstVisiblePosition >= 1) { headerHeight = mStickHeaderHeight; } return -top + firstVisiblePosition * child.getHeight() + headerHeight; }
Example #5
Source File: HighingRefreshListView.java From HighingRefresh with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (this.mOnScrollListener != null && refreshState != RefreshState.Refreshing) { this.mOnScrollListener.onScrollStateChanged(view, scrollState); } switch (scrollState) { // 当不滚动�? case OnScrollListener.SCROLL_STATE_IDLE: // 判断滚动到底�? if (this.getLastVisiblePosition() == (this.getCount() - 1)) { } // 判断滚动到顶�? if (this.getFirstVisiblePosition() == 0) { mIsTop = true; } else { mIsTop = false; } break; } }
Example #6
Source File: DialogPlus.java From dialogplus with Apache License 2.0 | 6 votes |
private void initExpandAnimator(Activity activity, int defaultHeight, int gravity) { Display display = activity.getWindowManager().getDefaultDisplay(); int displayHeight = display.getHeight() - Utils.getStatusBarHeight(activity); if (defaultHeight == 0) { defaultHeight = (displayHeight * 2) / 5; } final View view = holder.getInflatedView(); if (!(view instanceof AbsListView)) { return; } final AbsListView absListView = (AbsListView) view; view.setOnTouchListener(ExpandTouchListener.newListener( activity, absListView, contentContainer, gravity, displayHeight, defaultHeight )); }
Example #7
Source File: SwipyRefreshLayout.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
public boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; try { if (absListView.getCount() > 0) { if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) { int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition(); return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom(); } } } catch (Exception e) { e.printStackTrace(); } return true; } else { return true; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }
Example #8
Source File: DirectoryFragment.java From FireFiles with Apache License 2.0 | 6 votes |
@Override public void onDestroyView() { super.onDestroyView(); // Cancel any outstanding thumbnail requests final ViewGroup target = (mListView.getAdapter() != null) ? mListView : mGridView; final int count = target.getChildCount(); for (int i = 0; i < count; i++) { final View view = target.getChildAt(i); mRecycleListener.onMovedToScrapHeap(view); } // Tear down any selection in progress mListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE); mGridView.setChoiceMode(AbsListView.CHOICE_MODE_NONE); }
Example #9
Source File: PullToRefreshAdapterViewBase.java From SwipeMenuAndRefresh with Apache License 2.0 | 6 votes |
public final void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount) { if (DEBUG) { Log.d(LOG_TAG, "First Visible: " + firstVisibleItem + ". Visible Count: " + visibleItemCount + ". Total Items:" + totalItemCount); } /** * Set whether the Last Item is Visible. lastVisibleItemIndex is a * zero-based index, so we minus one totalItemCount to check */ if (null != mOnLastItemVisibleListener) { mLastItemVisible = (totalItemCount > 0) && (firstVisibleItem + visibleItemCount >= totalItemCount - 1); } // If we're showing the indicator, check positions... if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } // Finally call OnScrollListener if we have one if (null != mOnScrollListener) { mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } }
Example #10
Source File: BusyScrollListener.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { boolean isBusy = scrollState != AbsListView.OnScrollListener.SCROLL_STATE_IDLE; queuedIsBusy = isBusy; listView = view; handler.removeCallbacks(this); if (isBusy && !this.isBusy) { run(); } else if (!isBusy && this.isBusy) { handler.postDelayed(this, 250); } }
Example #11
Source File: FitGridAdapter.java From FitGridView with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View itemView, ViewGroup parent) { if (itemView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); itemView = inflater.inflate(itemId, parent, false); AbsListView.LayoutParams params = new AbsListView.LayoutParams(columnWidth, columnHeight); itemView.setLayoutParams(params); onBindView(position, itemView); } return itemView; }
Example #12
Source File: AudioBrowserFragment.java From VCL-Android with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { boolean enabled = scrollState == SCROLL_STATE_IDLE; if (enabled) { enabled = view.getFirstVisiblePosition() == 0; if (view.getChildAt(0) != null) enabled &= view.getChildAt(0).getTop() == 0; } mSwipeRefreshLayout.setEnabled(enabled); }
Example #13
Source File: SlidingLayout.java From CloudReader with Apache License 2.0 | 5 votes |
/** * 判断View是否可以下拉 * * @return canChildScrollDown */ public boolean canChildScrollDown() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; return absListView.getChildCount() > 0 && absListView.getAdapter() != null && (absListView.getLastVisiblePosition() < absListView.getAdapter().getCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1) .getBottom() < absListView.getPaddingBottom()); } else { return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, 1); } }
Example #14
Source File: SlideAndDragListViewActivity.java From SlideAndDragListView with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case AbsListView.OnScrollListener.SCROLL_STATE_IDLE: break; case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: break; case AbsListView.OnScrollListener.SCROLL_STATE_FLING: break; } }
Example #15
Source File: DropDownListView.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (isDropDownStyle) { if (currentScrollState == SCROLL_STATE_TOUCH_SCROLL && currentHeaderStatus != HEADER_STATUS_LOADING) { if (firstVisibleItem == 0 && actionMovePointY - actionDownPointY > 0 && mOffset == PAGE_MESSAGE_COUNT) { onDropDown(); } } else if (currentScrollState == SCROLL_STATE_FLING && firstVisibleItem == 0 && currentHeaderStatus != HEADER_STATUS_LOADING) { /** * when state of ListView is SCROLL_STATE_FLING(ListView is scrolling but finger has leave screen) and * first item(header layout) is visible and header status is not HEADER_STATUS_LOADING, then hide first * item, set second item visible and set hasReachedTop true. */ if (mOffset == PAGE_MESSAGE_COUNT){ onDropDown(); } hasReachedTop = true; } else if (currentScrollState == SCROLL_STATE_FLING && hasReachedTop) { setSelection(0); } } if (onScrollListener != null) { onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } }
Example #16
Source File: ImageRecyclerAdapter.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
void bindCamera(){ mItemView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mImageSize)); //让图片是个正方形 mItemView.setTag(null); mItemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!((ImageBaseActivity) mActivity).checkPermission(Manifest.permission.CAMERA)) { ActivityCompat.requestPermissions(mActivity, new String[]{Manifest.permission.CAMERA}, ImageGridActivity.REQUEST_PERMISSION_CAMERA); } else { imagePicker.takePicture(mActivity, ImagePicker.REQUEST_CODE_TAKE); } } }); }
Example #17
Source File: CrashRecordWindow.java From NetCloud_android with GNU General Public License v2.0 | 5 votes |
@Override protected TextView createItemView(int position) { TextView v = new TextView(getContext()); v.setTextColor(ResTools.getColor(R.color.text)); v.setTextSize(TypedValue.COMPLEX_UNIT_PX, (int)ResTools.getDimen(R.dimen.textsize2)); v.setGravity(Gravity.CENTER_VERTICAL); int hp = (int)ResTools.getDimen(R.dimen.hor_padding); int vp = (int)ResTools.getDimen(R.dimen.vtl_padding); v.setPadding(hp,vp,hp,vp); v.setOnClickListener(CrashRecordWindow.this); v.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int)ResTools.getDimen(R.dimen.item_height))); v.setBackgroundResource(R.drawable.list_item_bg); return v; }
Example #18
Source File: ResolverDrawerLayout.java From android-bottomsheet with ISC License | 5 votes |
private View findListChildUnder(float x, float y) { View v = findChildUnder(x, y); while (v != null) { x -= v.getX(); y -= v.getY(); if (v instanceof AbsListView || RECYCLERVIEW_CLASS_NAME.equals(v.getClass().getName())) { // One more after this. return findChildUnder((ViewGroup) v, x, y); } v = v instanceof ViewGroup ? findChildUnder((ViewGroup) v, x, y) : null; } return v; }
Example #19
Source File: ItemFragment.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_item, container, false); // Set the adapter mListView = (AbsListView) view.findViewById(android.R.id.list); ((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter); // Set OnItemClickListener so we can be notified on item clicks mListView.setOnItemClickListener(this); return view; }
Example #20
Source File: StatusScrollListener.java From YiBo with Apache License 2.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) { displayImage(view); } }
Example #21
Source File: Chapter07Activity.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
private void initView() { this.mListHeaderBtn = new Button(this); this.mChapterLV = (ListView) findViewById(R.id.isi_chapter_lv); this.mListHeaderBtn.setLayoutParams(new AbsListView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); this.mListHeaderBtn.setText("示例"); }
Example #22
Source File: ConsumeRecordActivity.java From letv with Apache License 2.0 | 5 votes |
public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case 0: if (this.this$0.saleNoteList != null && this.this$0.mAdapter != null && !this.this$0.isRequestData) { this.mTotalItemCount = this.mFirstVisibleItem + this.mVisibleItemCount; if (this.this$0.mListView.getFooterViewsCount() > 0) { this.mTotalItemCount--; } if (this.mTotalItemCount >= this.this$0.saleNoteList.size() && this.mTotalItemCount < Integer.parseInt(this.this$0.saleNoteList.totalCount)) { if (this.this$0.isNetErr) { this.this$0.showFooterLoading(); this.this$0.isNetErr = false; } this.this$0.currentPage = this.this$0.currentPage + 1; this.this$0.requestConsumerRecords(this.this$0.currentPage); return; } else if (this.this$0.mListView.getFooterViewsCount() > 0 && this.mTotalItemCount >= Integer.parseInt(this.this$0.saleNoteList.totalCount)) { this.this$0.removeFooterView(); return; } else { return; } } return; default: return; } }
Example #23
Source File: VelocityListView.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case SCROLL_STATE_IDLE: mTime = INVALID_TIME; setVelocity(0); break; default: break; } }
Example #24
Source File: DialogRootView.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Returns, whether a specific list view is scrolled to the top, or not. * * @param listView The list view as an instance of the class {@link AbsListView}. The list view may not * be null * @return True, if the given list view is scrolled to the top, false otherwise */ private boolean isListViewScrolledToTop(@NonNull final AbsListView listView) { if (listView.getFirstVisiblePosition() == 0) { if (listView.getChildCount() == 0) { return true; } else { View child = listView.getChildAt(0); return child == null || child.getTop() == 0; } } return false; }
Example #25
Source File: CustomListView.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
/** *这个方法,可能有点乱,大家多读几遍就明白了。 */ @Override public void onScrollStateChanged(AbsListView pView, int pScrollState) { if(mCanLoadMore){// 存在加载更多功能 if (mLastItemIndex == mCount && pScrollState == SCROLL_STATE_IDLE) { //SCROLL_STATE_IDLE=0,滑动停止 if (mEndState != ENDINT_LOADING) { if(mIsAutoLoadMore){// 自动加载更多,我们让FootView显示 “更 多” if(mCanRefresh){ // 存在下拉刷新并且HeadView没有正在刷新时,FootView可以自动加载更多。 if(mHeadState != REFRESHING){ // FootView显示 : 更 多 ---> 加载中... mEndState = ENDINT_LOADING; onLoadMore(); changeEndViewByState(); } }else{// 没有下拉刷新,我们直接进行加载更多。 // FootView显示 : 更 多 ---> 加载中... mEndState = ENDINT_LOADING; onLoadMore(); changeEndViewByState(); } }else{// 不是自动加载更多,我们让FootView显示 “点击加载” // FootView显示 : 点击加载 ---> 加载中... mEndState = ENDINT_MANUAL_LOAD_DONE; changeEndViewByState(); } } } }else if(mEndRootView != null && mEndRootView.getVisibility() == VISIBLE){ // 突然关闭加载更多功能之后,我们要移除FootView。 System.out.println("this.removeFooterView(endRootView);..."); mEndRootView.setVisibility(View.GONE); this.removeFooterView(mEndRootView); } }
Example #26
Source File: CountryAdapter.java From imsdk-android with MIT License | 5 votes |
@Override public void convert(CommonViewHolder viewHolder, CountryNode item) { final TextView tv_name = viewHolder.getView(R.id.name); final ImageView iv_sel_icon = viewHolder.getView(R.id.icon); if(item.isRoot) { viewHolder.getConvertView().setLayoutParams( new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, rootHeight)); viewHolder.getConvertView().setBackgroundResource(R.color.atom_ui_light_gray_ee); tv_name.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); iv_sel_icon.setVisibility(View.GONE); tv_name.setText(item.name); } else { tv_name.setText(item.name); tv_name.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); viewHolder.getConvertView().setLayoutParams( new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, nodeHeight)); if(item.resourceId == selectId) { iv_sel_icon.setVisibility(View.VISIBLE); } else { iv_sel_icon.setVisibility(View.INVISIBLE); } viewHolder.getConvertView().setBackgroundResource(R.color.atom_ui_white); } }
Example #27
Source File: SimpleMonthAdapter.java From Conquer with Apache License 2.0 | 5 votes |
public View getView(int position, View convertView, ViewGroup parent) { SimpleMonthView v; HashMap<String, Integer> drawingParams = null; if (convertView != null) { v = (SimpleMonthView) convertView; drawingParams = (HashMap<String, Integer>) v.getTag(); } else { v = new SimpleMonthView(mContext); v.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); v.setClickable(true); v.setOnDayClickListener(this); } if (drawingParams == null) { drawingParams = new HashMap<String, Integer>(); } drawingParams.clear(); final int month = position % MONTHS_IN_YEAR; final int year = position / MONTHS_IN_YEAR + mController.getMinYear(); int selectedDay = -1; if (isSelectedDayInMonth(year, month)) { selectedDay = mSelectedDay.day; } v.reuse(); drawingParams.put(SimpleMonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); drawingParams.put(SimpleMonthView.VIEW_PARAMS_YEAR, year); drawingParams.put(SimpleMonthView.VIEW_PARAMS_MONTH, month); drawingParams.put(SimpleMonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek()); v.setMonthParams(drawingParams); v.invalidate(); return v; }
Example #28
Source File: Util.java From dynamiclistview with MIT License | 5 votes |
public static boolean reachedListEnds(AbsListView listView) { boolean flag; if (reachedListTop(listView) || reachedListBottom(listView)) { flag = true; } else { flag = false; } return flag; }
Example #29
Source File: StickyListHeadersListView.java From Swface with Apache License 2.0 | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mOnScrollListenerDelegate != null) { mOnScrollListenerDelegate.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); } updateOrClearHeader(mList.getFixedFirstVisibleItem()); }
Example #30
Source File: ListViewExtend.java From Android-Next with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(view, scrollState); } if (DEBUG) { Log.v(TAG, "onScrollStateChanged() scrollState=" + scrollState); } if (SCROLL_STATE_IDLE == scrollState) { checkAutoRefresh(); } }