Android examples for java.lang.reflect:Field
set Int Field
//package com.java2s; import java.lang.reflect.Field; public class Main { public static void setIntField(Class clazz, String fieldName, int value) { Field field;//from w ww . j a v a 2s.c o m try { field = clazz.getField(fieldName); field.setInt(clazz, value); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }