Search code examples
androidrowgrid-layoutandroid-gridlayout

Remove one row from gridlayout


I'm using a GridLayout with 5 coloums and multiple (not a fix value) rows. It is possible to add more rows with values to the grid by a add button (the values are hardcoded in hashmap for now). In each row there is a delete button in the first cell. Now I want to implement, that if you hit the delete button, the complete row should be deleted but also other rows should stay. Any proposals how to do this?


Solution

  • You could remove the specific dataset from your HashMap (or use another map in the adapter for the dymanic content) and then call:

    grid.setRowCount(grid.getRowCount() - 1);
    grid.notifyDataSetChanged();
    

    That should remove the specific row.