Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用utf-8在android应用程序中显示印地语字体?_Android_Json_Utf 8 - Fatal编程技术网

如何使用utf-8在android应用程序中显示印地语字体?

如何使用utf-8在android应用程序中显示印地语字体?,android,json,utf-8,Android,Json,Utf 8,我开发了一个应用程序,该应用程序具有文本视图印地语和其他印地语显示功能,并使用json url从php mysql服务器获取数据,但问题是当我获得完美的英文显示数据时,但当我获得印地语和其他语言的数据时,其显示方式如下所示 什么是错误的背后,哪一边是php一边还是android一边 主要活动代码: public class JSONUseActivity extends Activity { String returnString; private Tex

我开发了一个应用程序,该应用程序具有文本视图印地语和其他印地语显示功能,并使用json url从php mysql服务器获取数据,但问题是当我获得完美的英文显示数据时,但当我获得印地语和其他语言的数据时,其显示方式如下所示

什么是错误的背后,哪一边是php一边还是android一边

主要活动代码:

 public class JSONUseActivity extends Activity {

        String returnString;  
        private TextView about;
        private ImageView image;
        String image_url;


        @Override
        public void onCreate(Bundle savedInstanceState) {
         StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
         .detectDiskReads().detectDiskWrites().detectNetwork() 
         .penaltyLog().build());
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_jsonuse);

           about=(TextView)findViewById(R.id.tv);
           Typeface tf=Typeface.createFromAsset(JSONUseActivity.this.getAssets(),"Shruti.ttf");
           about.setTypeface(tf);
           image=(ImageView)findViewById(R.id.iv);
           url_through_image.ImageLoader imgloader=new url_through_image.ImageLoader(getApplicationContext());
           ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();

           int loader = R.drawable.loader;
          postParameters.add(new BasicNameValuePair("temple_id",
          "2"));
              String response = null;

              try {
                  response = CustomHttpClient.executeHttpPost(
                          "url",  // in case of a remote server
           postParameters);


                  String result = response.toString();  


             try{
                     returnString = "";
               JSONArray jArray = new JSONArray(result);
                     for(int i=0;i<jArray.length();i++)
                     {
                             JSONObject json_data = jArray.getJSONObject(i);

                             returnString=json_data.getString("about_text");
                             image_url="url";

                     }
             }
             catch(JSONException e){
                     Log.e("log_tag", "Error parsing data "+e.toString());
             }

             try{
              about.setText(returnString);
              imgloader.DisplayImage(image_url, loader,image);
             }
             catch(Exception e){
              Log.e("log_tag","Error in Display!" + e.toString());;          
             }   
        }
              catch (Exception e) {
         Log.e("log_tag","Error in http connection!!" + e.toString());     
        }
             }         

        }



json parser is here..

     private static HttpClient getHttpClient() {

  if (mHttpClient == null) {
   mHttpClient = new DefaultHttpClient();

   final HttpParams params = mHttpClient.getParams();
   HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
   HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
   ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
  }

  return mHttpClient;
 }
    public static String executeHttpPost(String url,ArrayList<NameValuePair> postParameters) throws Exception {

        BufferedReader in = null;

      try {

       HttpClient client = getHttpClient();

       HttpPost request = new HttpPost(url);

       UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(

         postParameters,"UTF-8");

       request.setEntity(formEntity);

       HttpResponse response = client.execute(request);

       in = new BufferedReader(new InputStreamReader(response.getEntity()

         .getContent() ,"UTF-8"));



       StringBuffer sb = new StringBuffer("");

       String line = "";

       String NL = System.getProperty("line.separator");

       while ((line = in.readLine()) != null) {

        sb.append(line + NL);

       }

       in.close();


       String result = sb.toString();

       return result;

      } finally {

   if (in != null) {

    try {

     in.close();

    } catch (IOException e) {

     Log.e("log_tag", "Error converting result "+e.toString()); 

     e.printStackTrace();

    }

   }

  }

 }

 public static String executeHttpGet(String url) throws Exception {

  BufferedReader in = null;

  try {

   HttpClient client = getHttpClient();

   HttpGet request = new HttpGet();

   request.setURI(new URI(url));

   HttpResponse response = client.execute(request);

   in = new BufferedReader(new InputStreamReader(response.getEntity()

     .getContent(),"UTF-8"));


   StringBuffer sb = new StringBuffer("");

   String line = "";

   String NL = System.getProperty("line.separator");

   while ((line = in.readLine()) != null) {

    sb.append(line + NL);

   }

   in.close();


   String result = sb.toString();

   return result;

  } finally {

   if (in != null) {

    try {

     in.close();

    } catch (IOException e) {

     Log.e("log_tag", "Error converting result "+e.toString()); 

     e.printStackTrace();

    }

   }
  }

textview.setTypefaceTypeface.createFromAssetgetAssets,fonts/Hindi.ttf;试试这个..我已经用过了我的代码…好吧,我明白了,你试着把shruti.ttf改成印地语。ttfshruti,ttf是印地语和古吉拉特语的字体,所以我不认为这是我的眼睛。。。Shruti.ttf是印地语字体文件。。。。