本文整理匯總了Java中android.widget.AbsListView.getFirstVisiblePosition方法的典型用法代碼示例。如果您正苦於以下問題:Java AbsListView.getFirstVisiblePosition方法的具體用法?Java AbsListView.getFirstVisiblePosition怎麽用?Java AbsListView.getFirstVisiblePosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.getFirstVisiblePosition方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例2: canChildScrollUp
import android.widget.AbsListView; //導入方法依賴的package包/類
/**
* @return Whether it is possible for the child view of this layout to
* scroll up. Override this if the child view is a custom view.
*/
public boolean canChildScrollUp() {
// //For make it can work when my recycler view is in Gone.
// return false;
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTarget, -1);
}
}
示例3: onScrollToTopOrBottom
import android.widget.AbsListView; //導入方法依賴的package包/類
private void onScrollToTopOrBottom(AbsListView view) {
View childAt = view.getChildAt(0);
if (childAt == null) {
return;
}
//滑動到頂部
if (view.getFirstVisiblePosition() == 0 &&
childAt.getTop() >= 0) {
//It is scrolled all the way up here
if (mScrollChangeListener != null) {
mScrollChangeListener.onScrollToTop();
}
}
//滑動到底部
if (view.getLastVisiblePosition() == view.getAdapter().getCount() - 1 &&
view.getChildAt(
view.getChildCount() - 1).getBottom() <= view.getHeight()) {
if (mScrollChangeListener != null) {
mScrollChangeListener.onScrollToBottom();
}
}
}
示例4: onScrollStateChanged
import android.widget.AbsListView; //導入方法依賴的package包/類
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
// 判斷是否是停止滾動狀態
if (scrollState == SCROLL_STATE_IDLE) {
//獲取停止時第一個可見item位置
int firstVisiblePosition = absListView.getFirstVisiblePosition();
//獲取停止時最後一個可見item位置
int lastVisiblePosition = absListView.getLastVisiblePosition();
//去除SwipeListView刷新頭
if (firstVisiblePosition == 0 || firstVisiblePosition == lastVisiblePosition) {
return;
}
//添加監聽回饋
if (mListener != null) {
mListener.onStopVisibleItem(firstVisiblePosition, lastVisiblePosition);
}
}
}
示例5: defaultCanScrollUp
import android.widget.AbsListView; //導入方法依賴的package包/類
public static boolean defaultCanScrollUp(View view) {
if (view == null) {
return false;
}
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 ViewCompat.canScrollVertically(view, -1) || view.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(view, -1);
}
}
示例6: absListViewCanScrollList
import android.widget.AbsListView; //導入方法依賴的package包/類
/**
* Copy From AbsListView (API Level >= 19)
* @param absListView AbsListView
* @param direction Negative to check scrolling up, positive to check
* scrolling down.
* @return true if the list can be scrolled in the specified direction,
* false otherwise
*/
private boolean absListViewCanScrollList(AbsListView absListView,int direction) {
final int childCount = absListView.getChildCount();
if (childCount == 0) {
return false;
}
final int firstPosition = absListView.getFirstVisiblePosition();
if (direction > 0) {//can scroll down
final int lastBottom = absListView.getChildAt(childCount - 1).getBottom();
final int lastPosition = firstPosition + childCount;
return lastPosition < absListView.getCount() || lastBottom > absListView.getHeight() - absListView.getPaddingTop();
} else {//can scroll up
final int firstTop = absListView.getChildAt(0).getTop();
return firstPosition > 0 || firstTop < absListView.getPaddingTop();
}
}
示例7: 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;
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);
}
}
示例8: canScrollUp
import android.widget.AbsListView; //導入方法依賴的package包/類
private static boolean canScrollUp(View targetView) {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (targetView instanceof AbsListView) {
final AbsListView absListView = (AbsListView) targetView;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return targetView.getScrollY() > 0;
}
} else {
return targetView.canScrollVertically(-1);
}
}
示例9: isChildScrollToTop
import android.widget.AbsListView; //導入方法依賴的package包/類
/**
* 判斷目標View是否滑動到頂部-還能否繼續滑動
*
* @return
*/
public boolean isChildScrollToTop() {
if (Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
return !(absListView.getChildCount() > 0 && (absListView
.getFirstVisiblePosition() > 0 || absListView
.getChildAt(0).getTop() < absListView.getPaddingTop()));
} else {
return !(mTarget.getScrollY() > 0);
}
} else {
return !ViewCompat.canScrollVertically(mTarget, -1);
}
}
示例10: canViewScrollUp
import android.widget.AbsListView; //導入方法依賴的package包/類
private static boolean canViewScrollUp(View view) {
if (view instanceof AbsListView) {
// Pre-ICS we need to manually check the first visible item and the child view's top
// value
final AbsListView listView = (AbsListView) view;
return listView.getChildCount() > 0 &&
(listView.getFirstVisiblePosition() > 0
|| listView.getChildAt(0).getTop() < listView.getPaddingTop());
} else {
// For all other view types we just check the getScrollY() value
return view.getScrollY() > 0;
}
}
示例11: updateListViewScrollState
import android.widget.AbsListView; //導入方法依賴的package包/類
private void updateListViewScrollState(AbsListView listView) {
if (listView.getChildCount() == 0) {
setDraggable(true);
} else {
if (listView.getFirstVisiblePosition() == 0) {
View firstChild = listView.getChildAt(0);
if (firstChild.getTop() == listView.getPaddingTop()) {
setDraggable(true);
return;
}
}
setDraggable(false);
}
}
示例12: canChildScrollUp
import android.widget.AbsListView; //導入方法依賴的package包/類
public boolean canChildScrollUp() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0
|| absListView.getChildAt(0).getTop() < absListView.getPaddingTop());
} else {
return mTarget.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTarget, -1);
}
}
示例13: isListViewScrollOnTop
import android.widget.AbsListView; //導入方法依賴的package包/類
private static boolean isListViewScrollOnTop(AbsListView listView) {
if (listView.getChildCount() == 0) {
return true;
}
if (listView.getFirstVisiblePosition() > 0) {
return false;
}
View topChild = listView.getChildAt(0);
return topChild.getTop() >= 0;
}
示例14: canChildScrollUp
import android.widget.AbsListView; //導入方法依賴的package包/類
/**
* copy from {@link android.support.v4.widget.SwipeRefreshLayout#canChildScrollUp()}
*
* @return Whether it is possible for the child view of this layout to
* scroll up. Override this if the child view is a custom view.
*/
protected boolean canChildScrollUp() {
if (android.os.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);
}
}
示例15: isChildScrollToTop
import android.widget.AbsListView; //導入方法依賴的package包/類
/**
* 判斷目標View是否滑動到頂部-還能否繼續滑動
*
* @return
*/
public boolean isChildScrollToTop() {
if (Build.VERSION.SDK_INT < 14) {
if (((ViewGroup)mTarget).getChildAt(0) instanceof AbsListView) {
final AbsListView absListView = (AbsListView) ((ViewGroup)mTarget).getChildAt(0);
return !(absListView.getChildCount() > 0 && (absListView
.getFirstVisiblePosition() > 0 || absListView
.getChildAt(0).getTop() < absListView.getPaddingTop()));
} else {
return !(((ViewGroup)mTarget).getChildAt(0).getScrollY() > 0);
}
} else {
return !ViewCompat.canScrollVertically(((ViewGroup)mTarget).getChildAt(0), -1);
}
}