mercredi 1 avril 2015

Android : how to create a Object using Reflection and pass constructor parameter?

I'm trying a button using reflection in android, by the following code



public String createView(String classFullName){
try{
Class clazz = Class.forName(classFullName);

Object obj = clazz.newInstance(); // but I need to pass the Context using this;


}
catch(ClassNotFoundException ex){
return null;
}
}


but the main problem, is how to pass Context ( which is this in my case ) to the Object since they all should be a View.






Aucun commentaire:

Enregistrer un commentaire