Closed bogdanmunteanu closed 6 years ago
Hi @bogdanmunteanu
The first parameter is the clicked cell view holder. So, you can get what you want using TableViewListener.
@Override
public void onCellClicked(@NonNull RecyclerView.ViewHolder cellView, int column, int row) {
// if you have just one view type, you can directly cast your class.
if (cellView instanceof CellViewHolder) {
CellViewHolder cellViewHolder = (CellViewHolder) cellView;
}
....
}
Hi @evrencoskun ,
Yes, i knew that but the problem was that I did not how to access the layout . I did the following
Log.e("Order table listener::::" ,mTableView.getAdapter().getCellItem(column,row).toString());
Cell selectedCell =(Cell) mTableView.getAdapter().getCellItem(column,row);
CellViewHolder holder = (CellViewHolder) mTableView.getCellLayoutManager().getCellViewHolder(column,row);
if(holder!=null) {
holder.selectionImage.setVisibility(View.VISIBLE);
}
Also , I used butterknife in the holders because with findViewById in ocasionally throwed some NPEs.
@BindView(R.id.cell_container)
public LinearLayout cell;
@BindView(R.id.cell_data)
public TextView cellText;
@BindView(R.id.selectionCheck)
public ImageView selectionImage;
@BindView(R.id.ivNotAvailable)
public ImageView notAvailable;
public CellViewHolder(View itemView) {
super(itemView);
cell_textview = (TextView) itemView.findViewById(R.id.cell_data);
cell_container = (LinearLayout) itemView.findViewById(R.id.cell_container);
ButterKnife.bind(this,itemView);
}
All good and working. Thanks for your support , issue can be closed :+1: :+1:
Hi @evrencoskun,
I'm trying to show a selection state on TableView by displaying a green tick when the user clicks a specific cell.
Where I should put the code to make this happen ? From the table listener i cannot access the layout only the cell data.
This works ok , as it displays the correct data. I've tried also from the adapter but the click listener is not set. (This seems like the correct approach)
Is there a way of achieving this ?