Cleveroad / AdaptiveTableLayout

Library that makes it possible to read, edit and write CSV files
MIT License
1.9k stars 234 forks source link

adaptive table layout csv file issue #29

Closed sanduni closed 5 years ago

sanduni commented 6 years ago

how to pass custom object array list without using csv file? how to update particular cell?

PolarRoot commented 5 years ago

Good day @sanduni! Thx for using our library. You can use custom array list by this way:

Open library sample, open CsvFileDataSourceImpl and modify getRow method like this:

List getRow(int rowIndex) {

    ArrayList<ArrayList<String>> data = new ArrayList<>();

    ArrayList<String> tableHeader = new ArrayList<>();
    tableHeader.add("N");
    tableHeader.add("1");
    tableHeader.add("2");
    tableHeader.add("3");
    tableHeader.add("4");

    ArrayList<String> firstRow = new ArrayList<>();
    firstRow.add("1");
    firstRow.add("value 1");
    firstRow.add("value 2");
    firstRow.add("value 3");
    firstRow.add("value 4");

    ArrayList<String> secondRow = new ArrayList<>();
    secondRow.add("2");
    secondRow.add("value 1");
    secondRow.add("value 2");
    secondRow.add("value 3");
    secondRow.add("value 4");

    data.add(tableHeader);
    data.add(firstRow);
    data.add(secondRow);

    return data.get(rowIndex);

}

if you don't need to show empty cells, in method init() change value of mRowsCount to value of quantity of you rows: mRowsCount = data.size(); (for example)

With best regards Cleveroad team.