android反射:java.lang.NoSuchMethodException:

it2022-05-09  60

问题:在用反射时出现错误:java.lang.NoSuchMethodException: 方法名

解决:在网上搜了一下,这些错误均为出现,检查了以下发现int写成了Integer

 

具体反射用法:

Class<?> classMethod=Class.forName("类名"); Method method = classMethod.getMethod(方法名,方法参数); String result=(String)method.invoke(类实例,方法参数);

  

例:

Class<?> classMethod=Class.forName("com.Do.control.Soap"); Method method = classMethod.getMethod("contrl",String.class); String result=(String)method.invoke(LoginActivity.sDataStorage,mTerminalId);

转载于:https://www.cnblogs.com/Eudora/p/3498827.html

相关资源:数据结构—成绩单生成器

最新回复(0)