Android examples for java.lang.reflect:Class
print All Information about a class using reflection
//package com.java2s; import java.lang.reflect.Field; import java.lang.reflect.Method; import android.util.Log; public class Main { static public void printAllInform(Class clsShow) { try {/*from ww w. jav a 2s .c om*/ Method[] hideMethod = clsShow.getMethods(); int i = 0; for (; i < hideMethod.length; i++) { Log.e("method name", hideMethod[i].getName() + ";and the i is:" + i); } Field[] allFields = clsShow.getFields(); for (i = 0; i < allFields.length; i++) { Log.e("Field name", allFields[i].getName()); } } catch (SecurityException e) { // throw new RuntimeException(e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { // throw new RuntimeException(e.getMessage()); e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }