0
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 a 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 am able to see English and Hindi on the screen, but when it comes to Telugu it is just showing blank. I want Telugu also to be displayed. How can I achieve this?

David Medenjak
  • 33,993
  • 14
  • 106
  • 134
  • 1
    I'm not sure but try to change android studio's file encoding to utf-8. see here for more info http://stackoverflow.com/questions/30012529/android-studio-1-2-project-encoding-mismatches-by-default – Boukharist Jan 24 '16 at 20:30
  • 1
    You should read the official documentation. http://developer.android.com/training/basics/supporting-devices/languages.html – Endzeit Jan 24 '16 at 20:30

2 Answers2

0

You are probably using Roboto, the default font on android devices. Roboto supports many characters, but not all of them. Those languages not covered by Roboto are covered by Noto.

The Documentation says:

Language scripts that require extra line height to accommodate larger glyphs, including South and Southeast Asian and Middle-Eastern languages, like Arabic, Hindi, Telugu, Thai, Vietnamese. Noto supports these languages with two weights.

To fix your displaying issues you need to change your used font.

David Medenjak
  • 33,993
  • 14
  • 106
  • 134
0

To achieve this you need to create your custom adapter like this and set to spinner. Also Download proper font file eg. akshar.ttf file which support telugu language and put in assets folder of your 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 that 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 your color :)         

        return view;

    }
}
Rohit Sharma
  • 2,017
  • 1
  • 20
  • 22