Wednesday, 15 May 2013

Android nullPointException during Typeface -



Android nullPointException during Typeface -

i cannot understand problem. i've insert code:

string[] listoftext01 = {"r.id.text0101", "r.id.text0201"}; (int cont = 0; cont < listoftext01.length; cont++) { int arraytextid = getresources().getidentifier(listoftext01[cont], "id", getstring(r.string.packagename)); textview textlocation = (textview) findviewbyid(arraytextid); typeface fontname = typeface.createfromasset(getassets(), "fonts/robotocondensed-regular.ttf"); textlocation.settypeface(fontname); }

but @ row

typeface fontname = typeface.createfromasset(getassets(), "fonts/robotocondensed-regular.ttf");

return nullpointerexception. what's happen? working fine before set cicle dont understand what's happen. help me? thanks!

try way,hope help solve problem.

string[] listoftext01 = {"text0101", "text0201"}; try{ (int cont = 0; cont < listoftext01.length; cont++) { int arraytextid = getresources().getidentifier(listoftext01[cont], "id", getpackagename()); textview textlocation = (textview) findviewbyid(arraytextid); typeface fontname = typeface.createfromasset(getassets(), "fonts/robotocondensed-regular.ttf"); textlocation.settypeface(fontname); } }catch (throwable e){ e.printstacktrace(); }

android

No comments:

Post a Comment