Skip to content

Commit

Permalink
修复分页时加入多余的数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen2018 committed Jul 11, 2019
1 parent f0653b5 commit d386304
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public int getTableColumn() {

@Override
public int getTableRow() {
return 20;
return 220;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
View view = inflater.from(getActivity()).inflate(R.layout.fragment_table, container, false);
tableView = view.findViewById(R.id.tableView);
superTableViewAdapter = new TableAdapter(getActivity(), xTitles, itemTitles);
PagingMode pagingMode = new PagingMode(true,10,1,1);
PagingMode pagingMode = new PagingMode(true,50,50,2);
tableView.setPagingMode(pagingMode);
tableView.setTableViewAdapter(superTableViewAdapter);
// tableView.setOnVScrollChangeListener(new View.OnScrollChangeListener() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_table.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<com.ellen.tableview.supertableview.TableView
android:id="@+id/tableView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_height="wrap_content"
app:ItemHeight="50dp"
app:ItemWidth="120dp"
app:RowCount="10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int
if(scrollY+tableView.getHeight() > (tableView.getRowNumber()-pagingMode.getLoadBeforeSize())*tableView.getItemHeight()) {
if (tableView.getRowNumber() < tableViewAdapter.getTableRow()) {
for (int i = 0; i < pagingMode.getAddSize(); i++) {
if(tableView.getRowNumber() == tableViewAdapter.getTableRow())break;
SuperTableAdapter superTableAdapter = (SuperTableAdapter) tableViewAdapter;
superTableAdapter.addRow();
}
Expand All @@ -535,6 +536,7 @@ public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int
if(scrollX+tableView.getWidth()> (tableView.getColumnNumber()-pagingMode.getLoadBeforeSize())*tableView.getItemWidth()) {
if (tableView.getColumnNumber() < tableViewAdapter.getTableColumn()) {
for (int i = 0; i < pagingMode.getAddSize(); i++) {
if(tableView.getColumnNumber() == tableViewAdapter.getTableColumn())break;
SuperTableAdapter superTableAdapter = (SuperTableAdapter) tableViewAdapter;
superTableAdapter.addColumn();
}
Expand Down

0 comments on commit d386304

Please sign in to comment.