2016-05-23 4 views
-1

こんにちは なぜ文字列配列からテキストをロードし、textviewにテキストをセットするのが大きな文字列配列で非常に遅いのですか?文字列配列からテキストを読み込み、テキストをtextviewに設定するのが非常に遅い

私に助けてください。

//get khotbe text from database and copy to khotbe activity 
private void setkhotbetextarabicfarsi() { 
    this.sqliteDB = SQLiteDatabase.openOrCreateDatabase(this.getDatabasePath("aliname").getPath(), (SQLiteDatabase.CursorFactory) null); 

    Itemid = this.getIntent().getIntExtra("selectedFromListid", 1); 
    Cursor cursorLines = this.sqliteDB.rawQuery("SELECT * FROM khotbe where IDFehrest=" + this.Itemid , (String[]) null); 
    allrecs = cursorLines.getCount(); 
    matn = new String[allrecs]; 

    if (this.allrecs != 0) { 
     cursorLines.moveToFirst(); 

     for (int i = 0; i < this.allrecs; ++i) { 
      String TextArabicOfKhotbe = cursorLines.getString(cursorLines.getColumnIndex("TextArabicOfKhotbe")); 
      int IDkhotbe = cursorLines.getInt(cursorLines.getColumnIndex("IDkhotbe")); 


      this.matn[i] = TextArabicOfKhotbe;   

      cursorLines.moveToNext(); 
     } 
    } 

とメインコード:

for(int var1 = 0; var1 < this.allrecs; ++var1) { 

      tvArabic = new JustifiedTextView(this); 

      tvArabic.setText(matn[var1]); 

答えて

2

あなたはそれが遅くなっ可能性があるループ内textviewsを作成している。..アダプタを使用して配列の値を移入してみてください。..

もチェックDBからアクセスする行の数。彼らの数が膨大な場合は、取得に時間がかかります。 この場合、使用制限。

関連する問題