samedi 25 juin 2016

Android reflection access layout

Hello I am just want to know if I can access the layout of original class using reflection

i.e if I have a method like this

public void setData(int id){
editText1.setText(id+"");

}

and in refliction class , where c is the .class which I send(original class)

Object obj = c.newInstance();
        Method method1 = c.getMethod("setData", new Class[]{Integer.TYPE});
        method1.setAccessible(true);
        method1.invoke(obj, 3);

this code is working in the inside class(reflection one) but outside in the original it's like I didn't change anything





Aucun commentaire:

Enregistrer un commentaire