jeudi 22 septembre 2016

Modify value of non static variable - reflection

have a non-static int variable

public class MainActivity extends AppCompatActivity {
    @fields(key = "sample")
    public  int data = 2;
}

and I am trying to modify the content as:

bindHandler.getTargetField().setInt(bindHandler.getTarget(), 234);

This doesn't work. but when I change the variable in the MainActivity to :

@fields(key = "sample")
static public  int data = 2;

It works. How do make it work for non-static variable. Thanks





Aucun commentaire:

Enregistrer un commentaire