ISchwarz23 / SortableTableView

An Android library containing a simple TableView and an advanced SortableTableView providing a lot of customisation possibilities to fit all needs.
Apache License 2.0
1.05k stars 239 forks source link

I want just find solution this. onclickData problem. - read one single cell value. If you can tell tips #204

Open Hessu007 opened 3 years ago

Hessu007 commented 3 years ago

I new with the TableView component. Is there some one who can show me, how to read. one single Cell value. If i am understand right public void onDataClicked - just return RowIndex int value - that fine - but not columnIndex. Or is there something like getSelectedCellValue() function or... how to implement

@Override public void onDataClicked(int rowIndex, String[] strings) {

        final String carString = "Click: " + rowIndex;
        Toast.makeText(MainActivity.this, carString, Toast.LENGTH_SHORT).show();

Thanks for tips and support.

ISchwarz23 commented 3 years ago

Hi @Hessu007,

unfortunately, you can't listen for cell clicks. All clicks are related to a table item/row.

But in case you always want to get the first column value of the clicked row, you can implement it like this:

public void onDataClicked(int rowIndex, String[] strings) {
        final String contentOfFirstCell = strings[0];
        Toast.makeText(MainActivity.this, contentOfFirstCell, Toast.LENGTH_SHORT).show();
}

Kind regards

Baneeishaque commented 3 years ago

what about - using strings[columnIndex]? @Hessu007

ISchwarz23 commented 3 years ago

Unfortunately this is not possible. The click listener does not respect the column, only the row.