android - How to display text in Telugu language? -


protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     spinner spinner=(spinner) findviewbyid(r.id.spinner1);     spinner.setonitemselectedlistener(this);     list<string> categories=new arraylist<string>();     categories.add("select language");     categories.add("हिंदी");     categories.add("english");     categories.add("తెలుగు");     arrayadapter<string> dataadapter=new arrayadapter<string>(this,android.r.layout.simple_spinner_item,categories);     dataadapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);     spinner.setadapter(dataadapter); } 

i able see english , hindi on screen, when comes telugu showing blank. want telugu displayed. how can achieve this?

to achieve need create custom adapter , set spinner. download proper font file eg. akshar.ttf file support telugu language , put in assets folder of project:

import android.content.context; import android.content.res.assetmanager; import android.graphics.color; import android.graphics.typeface; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.textview;  public class languageadapter<t>  extends arrayadapter<t> {     assetmanager mngr;     public languageadapter(context ctx, t [] objects)     {         super(ctx, android.r.layout.simple_spinner_item, objects);             mngr = ctx.getassets();      }      //other constructors      @override     public view getdropdownview(int position, view convertview, viewgroup parent)     {         view view = super.getview(position, convertview, parent);          //we know simple_spinner_item has android.r.id.text1 textview:                    typeface faceakshar = typeface.createfromasset(mngr,"akshar.ttf");              textview text = (textview)view.findviewbyid(android.r.id.text1);             text.settypeface(faceakshar);             text.settextsize(24);             text.settextcolor(color.red);//choose color :)                   return view;      } } 

Comments