Atul Dhanuka Atul Dhanuka - 1 year ago 96
Android Question

How to change the gridview in listview

I am creating android application in which,
I need help that in click of button in which grid is write,
If we click that one then all the Listview in that activity should change to grid and button name change to list.

If again i click the Button then all grid should change to list.

Please help me out how i will do these thing in android project.

Thanks in Advance


Answer Source

Just implement a Grid View with numColumns=1 which will look like listview with single column

then on click of button

button.setOnClickListener(new View.onClickListener(){
   public void onClick(){
        gridview.setNumColumns(columns);//int columns as per your grid 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download