2013-12-18 30 views
2

我正在研究一個伊斯蘭應用程序。 我從Sq-lite數據庫中得到一個阿拉伯字符串,但是當我嘗試顯示這個字符串時,顯示不正確。 我也設置了編碼UTF-8的Java頁面。 但是當我直接使用這個字符串時,它顯示爲正確的樣式。 我也使用字體。但是沒有解決我的問題 任何機構都可以提供幫助嗎? 告訴我一些解決方案來解決這個問題。 我的代碼是在這裏..從android中的sqlite中獲取阿拉伯語字符串,不正確顯示?

String arabic ="ذَلِكَ الْكِتَابُ لَا رَيْبَ فِيهِ هُدًى لِلْمُتَّقِينَ"; 

當我使用這個它的工作原理。 但是當我從sqlite數據庫使用字符串它不顯示正確。

public class MainActivity extends Activity { 

//Variables..... 
TextView arabicTV,urduTV; 
TableLayout tablelayout; 
TableRow tableRow; 
Context context = this; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    tablelayout = (TableLayout)findViewById(R.id.tablelayout); 
    Typeface arabicFont = Typeface.createFromAsset(getAssets(), "Al Qalam Quran Publisher.ttf"); 

     DBAdapter db = new DBAdapter(this); 

     Cursor c =db.getAllAyyat(); 
     if(c.moveToFirst()){ 
      do{ 
       String value = c.getString(0); 
       System.out.println(value); 
       tableRow = new TableRow(this); 
       TableRow.LayoutParams lp = new  TableRow.LayoutParams(450, TableRow.LayoutParams.WRAP_CONTENT); 
       tableRow.setLayoutParams(lp); 
       lp.setMargins(4, 3, 6, 8); 
       arabicTV = new TextView(this); 
       arabicTV.setLayoutParams(lp); 
       arabicTV.setText(value); 
       arabicTV.setTypeface(arabicFont); 
       arabicTV.setBackgroundColor(Color.CYAN); 
       arabicTV.setPadding(3, 3, 3, 3); 
       arabicTV.setTextColor(Color.BLACK); 
       arabicTV.setTextSize(40); 
       tableRow.addView(arabicTV); 
       tablelayout.addView(tableRow); 
      }while(c.moveToNext()); 
     } 
    } 
+0

你能告訴我你的代碼? –

+0

@prince現在看我的代碼我更新這 – NadeemYousaf

+0

有什麼在日誌中:System.out.println(value); –

回答