0

我试图读取一个可能被某个人编码的字符串,但我需要读取这个字符串,实际上这个字符串是古吉拉特语,而且我还使用 .ttf 文件来读取这个古吉拉特语字符串

ઽૈરડૈર઻વૈયદ%ઐવરૄઇ)%ફ઻ષ઺ઐૅ%઼ઐ%ઃયર૎

我的主要问题是如何使这个字符串成为可读格式。

 public class ConnectDatabase extends Activity {
        private SimpleDBAdapter mDbHelper;
        private ListView list;
         private Typeface font;
         private String android_id;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            android_id = Secure.getString(getBaseContext().getContentResolver(),
                    Secure.ANDROID_ID);
            Log.i("me",android_id+"");
            Log.i("TAG","android.os.Build.SERIAL: " + Build.SERIAL);

            list = (ListView) findViewById(R.id.simpleListView);
            mDbHelper = new SimpleDBAdapter(ConnectDatabase.this);
            mDbHelper.createDatabase();
            mDbHelper.open();
            font = Typeface.createFromAsset(getAssets(), "mit.ttf");

            String[] values = mDbHelper.getEditTextValue();

            list.setAdapter( new MyCustAdapt(values));





        }




        class MyCustAdapt extends BaseAdapter{

            public String[] strv ;
            public LayoutInflater fInflater;
            public MyCustAdapt(String[] valuesstr) {
                // TODO Auto-generated constructor stub
                strv = valuesstr;
            }

            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                return strv.length;
            }

            @Override
            public Object getItem(int position) {
                // TODO Auto-generated method stub
                return position;
            }

            @Override
            public long getItemId(int position) {
                // TODO Auto-generated method stub
                return position;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                // TODO Auto-generated method stub


                LayoutInflater inflater = getLayoutInflater();
                View row;
                row = inflater.inflate(R.layout.mainlist_item, parent,false);

                TextView t = (TextView)row.findViewById(R.id.twAddress);

                t.setTypeface(font);
                t.setText(strv[position]);

               Log.i("Image",""+strv[position]);

                    return(row);
            }

        }
    }
4

1 回答 1

1

在您的 Android 应用程序的文件夹中添加您的古吉拉特语字体assets并使用以下代码

假设textBox是你的名字TextView

TextView myTextView=(TextView)findViewById(R.id.textBox);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/gujarati.ttf");
myTextView.setTypeface(typeFace);
于 2013-09-06T12:52:37.037 回答