reflect Class Method - Android java.lang.reflect

Android examples for java.lang.reflect:Method

Description

reflect Class Method

Demo Code


//package com.java2s;

import java.lang.reflect.Method;
import android.text.TextUtils;

public class Main {
     static Method reflectClassMethod(Class<?> clazz,
            String methodName, boolean isEqualsIgnoreCase) {
        if (clazz == null || TextUtils.isEmpty(methodName))
            return null;

        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            if ((isEqualsIgnoreCase && method.getName().equalsIgnoreCase(
                    methodName))//www. ja  v  a  2 s .  c  o  m
                    || method.getName().equals(methodName)) {
                return method;
            }
        }
        return null;
    }
}

Related Tutorials