getViewTypeCount should return the number of different views that the GridView will use. This number is used internally by Android to optimize the creation of views.
If all the elements in the form of a grid are of the same type, you must return 1.
@Override
public int getViewTypeCount() {
return 1;
}
There must be at least one kind of representation, and your implementation will probably return 0. That's why you get an exception.