ScrollablePanel
介绍:
一个二维可拖动的面板控件,交互像一个二维的RecyclerView,用法也非常简单和RecyclerView的用法基本一样,横向竖向滑动也都实现了View的复用,适合做房态、计划表、待办事项、课程表等 。
运行效果:
使用说明:
Demo
Apk Download:ScrollablePanelDemo.apk
Download
compile 'com.kelin.scrollablepanel:library:1.0.0'
ScrollablePanel用法和RecyclerView类似:
1、初始化 ScrollablePanel
<com.kelin.scrollablepanel.library.ScrollablePanel
android:id="@+id/scrollable_panel"
android:layout_width="match_parent"
android:layout_height="match_parent" />
2、Adapter
adapter必须继承PanelAdapter类,需要重写以下方法:
public class TestPanelAdapter extends PanelAdapter {
private List<List<String>> data;
@Override
public int getRowCount() {
return data.size();
}
@Override
public int getColumnCount() {
return data.get(0).size();
}
@Override
public int getItemViewType(int row, int column) {
return super.getItemViewType(row, column);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int row, int column) {
String title = data.get(row).get(column);
TitleViewHolder titleViewHolder = (TitleViewHolder) holder;
titleViewHolder.titleTextView.setText(title);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new TestPanelAdapter.TitleViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.listitem_title, parent, false));
}
private static class TitleViewHolder extends RecyclerView.ViewHolder {
public TextView titleTextView;
public TitleViewHolder(View view) {
super(view);
this.titleTextView = (TextView) view.findViewById(R.id.title);
}
}
}
3、Set Adapter
@Override
protected void onCreate(Bundle savedInstanceState) {
...
...
TestPanelAdapter testPanelAdapter = new TestPanelAdapter();
ScrollablePanel scrollablePanel = (ScrollablePanel) findViewById(R.id.scrollable_panel);
scrollablePanel.setPanelAdapter(testPanelAdapter);
...
...
}
已下载
0