You should work with screen sizes. The most common way I learned was to use a Resource with a Boolean is property (you can put whatever name you want, isGrid, for example), usually use isTablet.
First, you must create a values folder for each qualifier you have of layout. For example, if you have layout-land, layout-large-land, layout-xlarge then you should also have the values-land, values-large-land and values-xlarge folders.
Then you should create within each of the values folders a bool.xml file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="isGrid">false</bool>
</resources>
The value true or false changes according to the existence of gridView, if there is a gridView you must put true, otherwise false.
Now in Activity calling gridView or Listview you add the following code:
private boolean isGrid(){
return getResources().getBoolean(R.bool.isGrid);
}
Now in the onCreate method of the same Activity you must have a code with the following:
if(this.isGrid()){
//crie uma gridView
}
else{
//crie uma listView
}
Vlw for helping, I got a reply that worked really well. I posted it here so I can help others.
– ribeirojpn