You should work with screen sizes. The most common way I've learned was to use a resource with a boolean is property (you can put the name you want, isGrid for example), usually use isTablet.
First, you must create a values folder for each qualifier that you have to 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 a bool.xml file with the following contents inside each of the values folders:
<?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 the gridView, if there is a gridView you should set true, otherwise false.
Now in the activity that calls the gridView or the 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 should have a code with the following:
if(this.isGrid()){
//crie uma gridView
}
else{
//crie uma listView
}