本文整理汇总了Java中android.widget.AbsListView类的典型用法代码示例。如果您正苦于以下问题:Java AbsListView类的具体用法?Java AbsListView怎么用?Java AbsListView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbsListView类属于android.widget包,在下文中一共展示了AbsListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canChildScrollUp
import android.widget.AbsListView; //导入依赖的package包/类
/**
* Whether child view can scroll up
* @return
*/
public boolean canChildScrollUp() {
if (mTargetView == null) {
return false;
}
if (Build.VERSION.SDK_INT < 14) {
if (mTargetView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTargetView;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTargetView, -1);
}
}
示例2: onScrollStateChanged
import android.widget.AbsListView; //导入依赖的package包/类
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
Log.d("onScrollStateChanged", "totalItemCount = " + totalItemCount +
" lastVisibleItem = " + lastVisibleItem + " scrollState = " + scrollState);
if (totalItemCount + getHeaderViewsCount() + getFooterViewsCount() == lastVisibleItem && scrollState == SCROLL_STATE_IDLE) {
if (!isLoading) {
isLoading = true;
footer.findViewById(R.id.load_layout).setVisibility(View.VISIBLE);
// 加载更多
if (iLoadListener != null && !isLoadFinish) {
iLoadListener.onLoad();
} else {
//所有内容加载完毕
loadComplete(true);
}
}
}
}
示例3: setItemVisible
import android.widget.AbsListView; //导入依赖的package包/类
/**
* 隐藏或展示Item
*
* @param visible
*/
public void setItemVisible(boolean visible) {
if (null != itemView) {
if (visible) {
if (null != itemView.getLayoutParams()) {
itemView.getLayoutParams().width = AbsListView.LayoutParams.MATCH_PARENT;
itemView.getLayoutParams().height = AbsListView.LayoutParams.WRAP_CONTENT;
} else {
itemView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
}
itemView.setVisibility(View.VISIBLE);
} else {
if (null != itemView.getLayoutParams()) {
itemView.getLayoutParams().width = -1;
itemView.getLayoutParams().height = 1;
} else {
itemView.setLayoutParams(new AbsListView.LayoutParams(-1, 1));
}
itemView.setVisibility(View.GONE);
}
}
}
示例4: canChildScrollDown
import android.widget.AbsListView; //导入依赖的package包/类
public boolean canChildScrollDown() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
if (lastChild != null) {
return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
&& lastChild.getBottom() > absListView.getPaddingBottom();
} else {
return false;
}
} else {
return mTarget.getHeight() - mTarget.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTarget, 1);
}
}
示例5: canChildScrollUp
import android.widget.AbsListView; //导入依赖的package包/类
public static boolean canChildScrollUp(View view) {
if (Build.VERSION.SDK_INT < 14) {
if (view instanceof AbsListView) {
final AbsListView absListView = (AbsListView) view;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0
|| absListView.getChildAt(0).getTop() < absListView.getPaddingTop());
} else {
return ViewCompat.canScrollVertically(view, -1)
|| view.getScrollY() > 0;
}
} else {
if (Build.VERSION.SDK_INT < 26)
return ViewCompat.canScrollVertically(view, -1);
else
return view.canScrollVertically(-1);
}
}
示例6: highlightItems
import android.widget.AbsListView; //导入依赖的package包/类
private void highlightItems(List<String> items) {
if (items == null)
return;
if (items.size() > 1) {
// Required for us to select all the new items. Gets reset to normal when one is selected.
mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
}
int minIndex = Integer.MAX_VALUE;
for (String path: items) {
BookOrShelf item = _bookCollection.getBookByPath(path);
int bookIndex = _bookCollection.indexOf(item);
if (bookIndex >= 0) {
mListView.setItemChecked(bookIndex, true);
minIndex = Math.min(minIndex, bookIndex);
}
}
if (minIndex < Integer.MAX_VALUE) {
mListView.smoothScrollToPosition(minIndex);
}
}
示例7: onScrollStateChanged
import android.widget.AbsListView; //导入依赖的package包/类
public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) {
case 0:
this.imageLoader.resume();
break;
case 1:
if (this.pauseOnScroll) {
this.imageLoader.pause();
break;
}
break;
case 2:
if (this.pauseOnFling) {
this.imageLoader.pause();
break;
}
break;
}
if (this.externalListener != null) {
this.externalListener.onScrollStateChanged(view, scrollState);
}
}
示例8: canChildScrollUp
import android.widget.AbsListView; //导入依赖的package包/类
/**
* 用来判断是否可以下拉
*/
public static boolean canChildScrollUp(View mChildView) {
if (mChildView == null) {
return false;
}
if (Build.VERSION.SDK_INT < 14) {
if (mChildView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mChildView;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return ViewCompat.canScrollVertically(mChildView, -1) || mChildView.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mChildView, -1);
}
}
示例9: getAllCanScrollView
import android.widget.AbsListView; //导入依赖的package包/类
/**
* 递归遍历子view,记录所有的AbsListView, ScrollView
*
* @param absListViews
* @param parent
*/
private void getAllCanScrollView(List<AbsListView> absListViews,
List<ScrollView> scrollViews,
ViewGroup parent) {
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = parent.getChildAt(i);
if (child instanceof AbsListView) {
absListViews.add((AbsListView) child);
} else if (child instanceof ScrollView) {
scrollViews.add((ScrollView) child);
} else {
if (child instanceof ViewGroup) {
// 递归遍历子View
getAllCanScrollView(absListViews, scrollViews, (ViewGroup) child);
}
}
}
}
示例10: scrollToTop
import android.widget.AbsListView; //导入依赖的package包/类
private static boolean scrollToTop(View view) {
if (Build.VERSION.SDK_INT < 14) {
if (view instanceof AbsListView) {
final AbsListView absListView = (AbsListView) view;
return absListView.getChildCount() > 0
&& (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
|| absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
} else {
return ViewCompat.canScrollVertically(view, 1) || view.getScrollY() < 0;
}
} else {
return ViewCompat.canScrollVertically(view, 1);
}
}
示例11: fling
import android.widget.AbsListView; //导入依赖的package包/类
@Override
public void fling(int velocity) {
if (mScrollableView instanceof ScrollView) {
((ScrollView) mScrollableView).fling(velocity);
} else if (mScrollableView instanceof AbsListView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
((AbsListView) mScrollableView).fling(velocity);
}
} else if (mScrollableView instanceof WebView) {
((WebView) mScrollableView).flingScroll(0, velocity);
} else if (mScrollableView instanceof RecyclerView) {
((RecyclerView) mScrollableView).fling(0, velocity);
} else if (mScrollableView instanceof NestedScrollView) {
((NestedScrollView) mScrollableView).fling(velocity);
}
}
示例12: onItemLongClick
import android.widget.AbsListView; //导入依赖的package包/类
@Override
public boolean onItemLongClick(AdapterView<?> view, View row,
int position, long id) {
if (mMode == null) {
getGridView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
getGridView().invalidateViews();
mMode = mContext.startSupportActionMode(this);
} else {
getGridView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
getGridView().invalidateViews();
mMode.finish();
}
return (true);
}
示例13: onScrollStateChanged
import android.widget.AbsListView; //导入依赖的package包/类
/**
* 当滚动状态改变时回调
*/
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (onScrollListener != null) {
onScrollListener.onScrollStateChanged(view, scrollState);
}
if (scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_FLING) {
// 判断当前是否已经到了底部
if (footerView != null)
if (isScrollToBottom && !isLoadingMore) {
isLoadingMore = true;
// 当前到底部
Log.i(TAG, "加载更多数据");
footerView.setPadding(0, 0, 0, 0);
listView.setSelection(listView.getCount());
if (mOnRefershListener != null) {
mOnRefershListener.onLoadingMore();
}
}
}
}
示例14: canChildScrollUp
import android.widget.AbsListView; //导入依赖的package包/类
public static boolean canChildScrollUp(View view) {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (view instanceof AbsListView) {
final AbsListView absListView = (AbsListView) view;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return view.getScrollY() > 0;
}
} else {
return view.canScrollVertically(-1);
}
}
示例15: onScroll
import android.widget.AbsListView; //导入依赖的package包/类
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
mCurrentFirstVisibleItem = firstVisibleItem;
mCurrentVisibleItemCount = visibleItemCount;
mPreviousFirstVisibleItem = (mPreviousFirstVisibleItem == -1) ? mCurrentFirstVisibleItem
: mPreviousFirstVisibleItem;
mPreviousVisibleItemCount = (mPreviousVisibleItemCount == -1) ? mCurrentVisibleItemCount
: mPreviousVisibleItemCount;
checkAndHandleFirstVisibleCellChange();
checkAndHandleLastVisibleCellChange();
mPreviousFirstVisibleItem = mCurrentFirstVisibleItem;
mPreviousVisibleItemCount = mCurrentVisibleItemCount;
if (isPostHoneycomb() && mWobbleInEditMode) {
updateWobbleState(visibleItemCount);
}
if (mUserScrollListener != null) {
mUserScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
}
}