本文整理汇总了Java中android.widget.AbsListView.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.getCount方法的具体用法?Java AbsListView.getCount怎么用?Java AbsListView.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.getCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: canChildScrollDown
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
protected boolean canChildScrollDown() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
return absListView.getChildCount() > 0
&& (absListView.getLastVisiblePosition() < absListView.getCount() - 1 ||
absListView.getChildAt(absListView.getChildCount() - 1).getBottom() >
absListView.getHeight() - absListView.getPaddingBottom());
} else {
return ViewCompat.canScrollVertically(mTarget, 1);
}
} else {
return ViewCompat.canScrollVertically(mTarget, 1);
}
}
示例5: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
mFirstVisibleItem = firstVisibleItem;
if (view.getFirstVisiblePosition() == 1) {
mIsTop = true;
} else if (view.getLastVisiblePosition() == view.getCount() - 1) {
mIsBottom = true;
} else {
mIsTop = false;
mIsBottom = false;
}
}
示例6: isReadyForPull
import android.widget.AbsListView; //导入方法依赖的package包/类
public boolean isReadyForPull(View view, float x, float y) {
AbsListView absListView = (AbsListView) view;
if (absListView.getCount() == 0) {
return true;
}
if (absListView.getFirstVisiblePosition() != 0) {
return false;
}
View firstVisibleChild = absListView.getChildAt(0);
boolean ready = firstVisibleChild != null && firstVisibleChild.getTop() >= absListView
.getPaddingTop();
return ready;
}
示例7: refresh
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* Check if some thumbnails are needed.
* To be called to restart the Thumbnail engine after is has been stopped, for some reason.
* ('listView' has to be given by the caller because ThumbnailRequester doesn't know it (it only gets callbacks from it))
*/
public void refresh(AbsListView listView) {
// First be sure that onScrollStateChanged() won't think it has not moved, hence need no request
reset();
// Sanity check
if (listView.getCount()<1) {
return;
}
// Simulate an onScroll call
onScroll( listView, listView.getFirstVisiblePosition(),
listView.getLastVisiblePosition()-listView.getFirstVisiblePosition(),
listView.getCount());
}
示例8: restoreBestPositionWithScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* Restore the best position possible in the list.
*
* @return the new last position
*/
public static int restoreBestPositionWithScroll(final AbsListView listView, int selectedPosition,
int firstVisiblePosition, final int scroll) {
if(listView.getFirstVisiblePosition() <= selectedPosition && listView.getLastVisiblePosition()>=selectedPosition)
return selectedPosition;
final int newPositionToSelect;
newPositionToSelect = selectedPosition>=0?selectedPosition:0;
if (newPositionToSelect < listView.getCount()) {
//we select next enabled view
for(int i = newPositionToSelect; i<listView.getCount(); i++){
if(i<listView.getAdapter().getCount()&&listView.getAdapter().isEnabled(i)){
//we don't want to loose scroll
final int pos = i;
if(listView instanceof GridView){
listView.setSelection(pos);
listView.smoothScrollToPositionFromTop(pos, scroll);
}
else if(listView instanceof ListView)
((ListView)listView).setSelectionFromTop(pos, scroll);
break;
}
}
// Make sure the album list/grid has still the focus after changing the
// view mode
listView.postDelayed(new Runnable() {
@Override
public void run() {
listView.requestFocus();
}
}, 200);
}
return newPositionToSelect;
}