excelPanel
介绍:
RecyclerView实现的二维表格,实现了“加载更多”功能。
运行效果:
使用说明:
Including in your project
compile 'cn.zhouchaoyuan:excelpanel:1.0.0'
1、 xml
<cn.zhouchaoyuan.excelpanel.ExcelPanel
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cell_background="@color/normal_cell_bg"
app:left_cell_width="@dimen/room_status_cell_length"
app:normal_cell_length="@dimen/room_status_cell_length"
app:top_cell_height="@dimen/room_status_cell_length" />
配置xml属性
app:cell_background="@color/normal_cell_bg" //container cell's background
app:left_cell_width="@dimen/room_status_cell_length" //left header cell's width
app:normal_cell_length="@dimen/room_status_cell_length" //container cell's width
app:top_cell_height="@dimen/room_status_cell_length" //top header cell's width
2、定义级的Adapter
你的adapter必须继承BaseExcelPanelAdapter并重写如下7个方法:
public class Adapter extends BaseExcelPanelAdapter<RowTitle, ColTitle, Cell>{
public Adapter(Context context) {
super(context);
}
//=========================================normal cell=========================================
@Override
public RecyclerView.ViewHolder onCreateCellViewHolder(ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindCellViewHolder(RecyclerView.ViewHolder holder, int verticalPosition, int horizontalPosition) {
}
//=========================================top cell===========================================
@Override
public RecyclerView.ViewHolder onCreateTopViewHolder(ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindTopViewHolder(RecyclerView.ViewHolder holder, int position) {
}
//=========================================left cell===========================================
@Override
public RecyclerView.ViewHolder onCreateLeftViewHolder(ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindLeftViewHolder(RecyclerView.ViewHolder holder, int position) {
}
//=========================================top left cell=======================================
@Override
public View onCreateTopLeftView() {
return null;
}
}
3、使用你的Adapter
//==============================
private List<RowTitle> rowTitles;
private List<ColTitle> colTitles;
private List<List<Cell>> cells;
private ExcelPanel excelPanel;
private CustomAdapter adapter;
private View.OnClickListener blockListener
//..........................................
excelPanel = (ExcelPanel) findViewById(R.id.content_container);
adapter = new CustomAdapter(this, blockListener);
excelPanel.setAdapter(adapter);
excelPanel.setOnLoadMoreListener(this);//your Activity or Fragment implement ExcelPanel.OnLoadMoreListener
adapter.setAllData(colTitles, rowTitles, cells);
adapter.enableFooter();//load more
adapter.enableHeader();//load history
如果你使用 setOnLoadMoreListener(...) 与 enableHeader() ,必须调用 addHistorySize(int)告诉ExcelPanel添加了多少数据。
已下载
0