试图从包中访问类

时间:2014-05-15 12:31:56

标签: java android reflection

我正在开发一个Android测试应用程序,我将访问所有内部类的android.view包。 android.view是一个包含在jar文件中的包。我尝试通过加载包名称,但它不显示这里的类我使用过滤器和classLoadersList仍然我没有得到列表视图中的输出,如果任何人已经尝试过这个,请帮助

public class ClassDisplay_list {
    public int i,j;

    public static void main(){
        Log.i("in display main function" ,"i am ");

        List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();

        classLoadersList.add(ClasspathHelper.getContextClassLoader());
        classLoadersList.add(ClasspathHelper.getStaticClassLoader());

        Reflections reflections = new Reflections(new ConfigurationBuilder()
            .setScanners(new SubTypesScanner(), new ResourcesScanner())
            .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
            .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("android.view"))));

        Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
        Iterator it=classes.iterator();

        while(it.hasNext()){
            Class c=(Class)it.next();
            String classname = c.getName();
            ClassesDisplayActivity.your_array_list3.add(classname);
            Log.i("Ram","class name "+ c.getName());
        }
    }
}

0 个答案:

没有答案