tags:

views:

52

answers:

1

I am beginner in Android development. At the moment, I am working a calculator. I want to use GridView in button part, but i have one error:

Caused by:java.lang.IllegalArgumentException: can't have a viewTypeCount < 1

First i make class ButtonAdapter and implements ListAdapter. But i cant understand this error.

Please help me

+1  A: 

getViewTypeCount should return the number of different views your GridView will be using. This number is used internally by Android to optimize view creation.

If all of items in your grid view are the same type, you should return 1.

@Override
public int getViewTypeCount() {
    return 1;
}

There should be at least one type of the view, and your implementation probably returns 0. That's why you're getting the exception.

uaraven