开发者

How do i highlight a number of characters in a listview

Hi i currently have a listview that needs characters at a certain calculated position in a string to be changed to another color. Eg. I want something like this:

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

to appear in the listview

Kind of like using SpannableString on a normal textview but the array does not accept Spannable strings objects. This is currently what i have. the generatestring() medthod will update the field 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);
         开发者_如何学Python       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)
        {
        }
        
        }


just take custom adapter and set your layout as you wish

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜