android - Change TextView font which is not in activity_main.xml -


i have listview. contains 3 textview not activity_main.xml.

   cursor = mydatabase.getjoinedinfo(etsearch.gettext().tostring().trim());          string[] columns = new string[] { "re_value", "g_value", "ke_value" };          int[] = new int[] { r.id.tvhiragana, r.id.tvmeaning, r.id.tvkanji };          dataadapter = new simplecursoradapter(this, r.layout.wordonlist,                 cursor, columns, to, 0);          // assign adapter listview          listview.setadapter(dataadapter); 

how change font of textviews inside listview?

final typeface mfont = typeface.createfromasset(getassets(),             "fonts/himaji.otf");     layoutinflater ltinflater = getlayoutinflater();     view view = ltinflater.inflate(r.layout.wordonlist, null, false);     tvhiragana=(textview) view.findviewbyid(r.id.tvhiragana);     tvhiragana.settypeface(mfont); 

this code not change textview's font. doing wrong?

you can style textviews in xml (e.g. row layout), outlined in styles , themes article.

if need programmatically change font (e.g. instances, or using parameters not known @ compile-time), create anonymous subclass (or regular subclass) of simplecursoradapter applies changes in adapter's getview method. that, see slightly related answer text color changing. code inflates layout (thus creating new view instance), , changes single instance, not instances added list.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -