Java Reflection in android -
this typeface
class
public class typeface { public static final typeface rupee(context ctx){ typeface typeface = typeface.createfromasset(ctx.getassets(), "rupee_foradian.ttf"); return typeface; } public static final typeface arialrounded(context ctx){ typeface typeface = typeface.createfromasset(ctx.getassets(), "rupee_foradian.ttf"); return typeface; } }
and try access methods class using reflection following way
method method; typeface typeface; try{ method = typeface.getclass().getmethod("rupee",context.class); }catch(exception e){ system.out.println("method : "+e); }
but throws nullpointerexception
.
05-21 17:12:07.026: i/system.out(14917): method : java.lang.nullpointerexception
i dont know wrong way. sombody can me please.
thanks in advance.
typeface
null
, because it's not initialized
change typeface typeface = new typeface();
Comments
Post a Comment