Android examples for java.lang.reflect:ParameterizedType
get Class Generic Type
//package com.java2s; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { private static Type getGenericType(int index, Class<?> subclass) { Type superclass = subclass.getGenericSuperclass(); if (!(superclass instanceof ParameterizedType)) { return Object.class; }//from www. ja v a2 s . c om Type[] params = ((ParameterizedType) superclass) .getActualTypeArguments(); if (index >= params.length || index < 0) { throw new RuntimeException("Index outof bounds"); } if (!(params[index] instanceof Class)) { return Object.class; } return params[index]; } }