This piece of code gets resources from a list and set errors for each field on a registration form, one of them is a spinner, so when the error is on the spinner, it fails due to the fact that the spinner is not a subclass of TextView. How can I get this code deal with the spinner in an elegant way?

```
// set errors
        for (Map.Entry<String, List<String>> error : errors.entrySet()) {
            int id = getActivity().getResources().getIdentifier("edit_" + error.getKey(), "id", getActivity().getPackageName());
            //TODO this codes doen't manage spinner errors! (checkboxes and editext are both TextView)
            TextView edit = (TextView) getActivity().findViewById(id);
            if (!error.getValue().isEmpty()) {
                edit.setError(error.getValue().get(0));
            }
        }

```