本文整理匯總了Java中android.support.v7.widget.LinearLayoutManager.getChildCount方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayoutManager.getChildCount方法的具體用法?Java LinearLayoutManager.getChildCount怎麽用?Java LinearLayoutManager.getChildCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.getChildCount方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDraw
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
final RecyclerView.LayoutManager manager = parent.getLayoutManager();
if (manager instanceof StaggeredGridLayoutManager) {
return;
}
//線性布局
final LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
final int firstItem = layoutManager.findFirstVisibleItemPosition();
for (int i = 0; i < layoutManager.getChildCount(); i++) {
final int viewAdapterPosition = firstItem + i;
final View view = layoutManager.findViewByPosition(viewAdapterPosition);
if (view != null) {
mItemDecorationCallback.draw(c, mTextPaint, view,
mItemDecorationCallback.getItemOffsets(layoutManager, viewAdapterPosition),
layoutManager.getItemCount(), viewAdapterPosition);
}
}
}
示例2: processLoadMoreData
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private void processLoadMoreData() {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) display.getLayoutManager();
int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
int totalCount = linearLayoutManager.getItemCount();
int visibleCount = linearLayoutManager.getChildCount();
// 這裏分兩種情況,當緩慢滑動的時候,邊滑動邊加載,沒有接觸到底部。當如果快速滑動的時候,還沒加載完就滑動到底部
if ((firstVisibleItemPosition + visibleCount >= totalCount) && !isLoading && totalCount != 1) {
LogUtil.e("底部加載拉");
if (mOnMoreDataLoadListener != null) {
isLoading = true;
moreLoadView.setVisibility(VISIBLE);
mOnMoreDataLoadListener.onMoreDataLoad(totalCount, firstVisibleItemPosition);
}
}
}
示例3: needToRequestNextPage
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private boolean needToRequestNextPage() {
LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = getAdapter().getItemCount();
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
return firstVisibleItemPosition > 0 && firstVisibleItemPosition + visibleItemCount > totalItemCount - 5;
}
示例4: isAtLastElementOfLinearLayoutManager
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
private boolean isAtLastElementOfLinearLayoutManager(LinearLayoutManager linearLayoutManager) {
visibleItemCount = linearLayoutManager.getChildCount();
totalItemCount = linearLayoutManager.getItemCount();
pastVisibleItems = linearLayoutManager.findFirstVisibleItemPosition();
return (visibleItemCount + pastVisibleItems) >= totalItemCount - VISIBILITY_THRESHOLD;
}
示例5: onDraw
import android.support.v7.widget.LinearLayoutManager; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDraw(c, parent, state);
final RecyclerView.LayoutManager manager = parent.getLayoutManager();
int itemCount = manager.getItemCount();
if (itemCount < 1) {
//如果隻有1個item, 直接返回;
return;
}
if (manager instanceof GridLayoutManager) {
//網格布局
drawGrid(c, manager);
} else if (manager instanceof StaggeredGridLayoutManager) {
//暫不支持...
} else {
//線性布局
final LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
final int firstItem = layoutManager.findFirstVisibleItemPosition();
for (int i = 0; i < layoutManager.getChildCount(); i++) {
int adapterPosition = firstItem + i;
final View view = layoutManager.findViewByPosition(adapterPosition);
if (itemCount == 1 || adapterPosition == itemCount - 1) {
//第一個, 或者最後一個
if (!drawLastHLine && !drawLastVLine) {
continue;
}
}
if (view != null) {
if (layoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
//水平
drawDrawableV(c, view);
} else {
//垂直
drawDrawableH(c, view);
}
}
}
}
}