Am trying to develop an android app. I use a grid view in it and I want to place one button each in each of the cells. Now I entered some values into the grid view using List. I will show it :
GridView gv; //
List<String> array; // Declaration
gv = (GridView) findViewById(R.id.gridView1); //
array = new ArrayList<String>(); // Initialization
array.add("1"); //
array.add("2"); //
array.add("3"); // adding values to grid view
gv.setAdapter(new ListArray(MainActivity.this, array));
Is it possible to add buttons instead of these values ? Please explain the steps with an example.
You have to create a custom grid view for that purpose, You can have more than one view like text or button on a single block of GridView, here is the link custom-grid-view-example
You can use the button instead of image using the above example and can perform the operations as you want.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments