2011-05-05 71 views
-1

您好我目前有一個列表視圖需要字符在字符串中的某個計算位置被更改爲另一種顏色。例如。我想是這樣的:我如何突出顯示列表視圖中的字符數

Randomstuffhere 2011年4月4日05:44 2011年4月4日05:44

Randomstuff 2011年4月4日05:43 2011/4/4 05:44

Somethingelse 2011年4月4日05:41 2011年4月4日05:44

出現在列表視圖等使用上的正常的TextView SpannableString但陣列不接受Spannable字符串對象

類。這是目前我所擁有的。 generatetring()方法將更新字段temphistoricweekdata。

private void populatearray() { 
     try 
     { 
      results.clear(); 
      historicweek = getListView(); 
      db = openOrCreateDatabase(DB_NAME, SQLiteDatabase.CREATE_IF_NECESSARY, null); 
      Cursor timesheetCursor = db.rawQuery("SELECT id, starttime, endtime, starttime1,endtime1 FROM timesheet WHERE year = (SELECT MAX(year) FROM timesheet) and week =(SELECT MAX(week) FROM timesheet where year = (SELECT MAX(year) FROM timesheet));", null); 

      timesheetCursor.moveToFirst(); 

      while (!timesheetCursor.isAfterLast()){ 

       int iddata = timesheetCursor.getInt(0); 
       idArrayHistoric.add(iddata); 
       DateAA = timesheetCursor.getString(1); 
       DateBB = timesheetCursor.getString(2); 
       DateCC = timesheetCursor.getString(3); 
       DateDD = timesheetCursor.getString(4); 


       generatestring(); 

       results.add(temphistoricweekdata); 
       timesheetCursor.moveToNext(); 
      } 
      timesheetCursor.close(); 
      db.close(); 
     historyadapter = new ArrayAdapter<String>(this, R.layout.list_white_text,R.id.list_content,results); 
     this.setListAdapter(historyadapter); 
     } 

     catch (SQLiteException se) 
     { 
     } 

     } 

回答

1

只是需要自定義適配器,並設置您的佈局,如你所願

+0

私人的ArrayList 結果=新的ArrayList ();我想到了。 – Thanks 2011-05-05 03:44:49

相關問題