Setting a typeface to text in listview in android -


i want set typeface of list view araliya.ttf. here code. there no error typeface in listview text not changed.(it changed in textviews , buttons) can please tell me wrong in here. thankyou..

public class mycustomadapter extends arrayadapter<item> {          private arraylist<item> itemlist;         typeface tf;          public mycustomadapter(context context, int textviewresourceid,                                arraylist<item> itemlist) {             super(context, textviewresourceid, itemlist);             this.itemlist = new arraylist<item>();             this.itemlist.addall(itemlist);            // tf = typeface.createfromasset(context.getassets(), "araliya.ttf");         }          private class viewholder {             textview code;             checkbox name;         }          @override         public view getview(int position, view convertview, viewgroup parent) {              viewholder holder = null;             log.v("convertview", string.valueof(position));              if (convertview == null) {                 layoutinflater vi = (layoutinflater)getsystemservice(                         context.layout_inflater_service);                 convertview = vi.inflate(r.layout.symptom_info, null);                 sinfont = typeface.createfromasset(getassets(), "araliya.ttf");                 holder = new viewholder();                 holder.code = (textview) convertview.findviewbyid(r.id.code);                 holder.code.settypeface(sinfont);                 holder.name = (checkbox) convertview.findviewbyid(r.id.checkbox1);                 holder.name.settypeface(sinfont);                 convertview.settag(holder); 

here code in oncreate()

dataadapter = new mycustomadapter(this,                 r.layout.symptom_info, itemlist);         listview listview = (listview) findviewbyid(r.id.listview1);         listview.setadapter(dataadapter);           listview.setonitemclicklistener(new adapterview.onitemclicklistener() {             public void onitemclick(adapterview<?> parent, view view,                                     int position, long id) {                 // when clicked, show toast textview text                 item item = (item) parent.getitematposition(position);              }         }); 

update - issue resolved

textview t1 = (textview)findviewbyid(r.id.textview2);  t1.settypeface(sinfont); t1.settext("my,ska m%fnoh f;dard.kak");  

this works , change typeface of text in textview.

i pretty sure that, haven't set path right.

typeface sinfont = typeface.createfromasset(getassets(), "araliya.ttf"); 

here araliya.ttf not correct path. should fonts/araliya.ttf.

actually seconds argument inside createfromasset stands path font. if have put font in assets/fonts. below required code initialise font.

string path = "fonts/araliya.ttf" typeface sinfont = typeface.createfromasset(getassets(), path); 

then set font using

holder.code.settypeface(sinfont); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -