本文整理汇总了Java中com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter.setSpanSizeLookup方法的典型用法代码示例。如果您正苦于以下问题:Java LRecyclerViewAdapter.setSpanSizeLookup方法的具体用法?Java LRecyclerViewAdapter.setSpanSizeLookup怎么用?Java LRecyclerViewAdapter.setSpanSizeLookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter
的用法示例。
在下文中一共展示了LRecyclerViewAdapter.setSpanSizeLookup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_ll_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (LRecyclerView) findViewById(R.id.list);
mRecyclerView.setLayoutManager(new GridLayoutManager(this,2));
mVisitables = getData();
mMainAdapter = new MainAdapter(new ListTypeFactory(), mVisitables);
mLRecyclerViewAdapter = new LRecyclerViewAdapter(mMainAdapter);
mRecyclerView.setAdapter(mLRecyclerViewAdapter);
mLRecyclerViewAdapter.setSpanSizeLookup(new LRecyclerViewAdapter.SpanSizeLookup() {
@Override
public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
Object item = mVisitables.get(position);
return (item instanceof HotList || item instanceof ProductList || item instanceof Category) ? gridLayoutManager.getSpanCount() : 1;
}
});
mLRecyclerViewAdapter.addHeaderView(new SampleHeader(this));
mRecyclerView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mRecyclerView.refreshComplete(10);
}
},1000);
}
});
mRecyclerView.refresh();
mRecyclerView.setLoadMoreEnabled(false);
//是否允许嵌套滑动
mRecyclerView.setNestedScrollingEnabled(false);
}
示例2: onCreate
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_ll_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (LRecyclerView) findViewById(R.id.list);
mRecyclerView.setNestedScrollingEnabled(false);
mShopAdapter = new ShopAdapterBase(this,mGoodsList);
//setLayoutManager must before setAdapter
GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
mRecyclerView.setLayoutManager(layoutManager);
initData();
mLRecyclerViewAdapter = new LRecyclerViewAdapter(mShopAdapter);
mRecyclerView.setAdapter(mLRecyclerViewAdapter);
mShopAdapter.addAll(mItemModels);
DividerDecoration divider = new DividerDecoration.Builder(this)
.setHeight(R.dimen.default_divider_height)
.setPadding(R.dimen.default_divider_padding)
.setColorResource(R.color.split)
.build();
mRecyclerView.setHasFixedSize(true);
mRecyclerView.addItemDecoration(divider);
mLRecyclerViewAdapter.setSpanSizeLookup(new LRecyclerViewAdapter.SpanSizeLookup() {
@Override
public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
MultipleItem item = mShopAdapter.getDataList().get(position);
if (item.getItemType() == MultipleItem.LIST) {
return gridLayoutManager.getSpanCount();
} else {
return 1;
}
}
});
mLRecyclerViewAdapter.addHeaderView(new SampleHeader(this));
mRecyclerView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mRecyclerView.refreshComplete(10);
}
},1000);
}
});
mRecyclerView.refresh();
//是否允许嵌套滑动
mRecyclerView.setNestedScrollingEnabled(false);
}