如何在Android中读取加密字符串

时间:2013-09-06 12:46:44

标签: java android

我尝试读取一个可能被某个编码的字符串,但是我需要读取这个字符串, 实际上这个字符串是Gujrati语言,而且我也使用.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);
            }

        }
    }

1 个答案:

答案 0 :(得分:1)

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

假设 textBox 是您的TextView

的名称
TextView myTextView=(TextView)findViewById(R.id.textBox);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/gujarati.ttf");
myTextView.setTypeface(typeFace);