here is the attempt with Spannable, text does not change???
fun getAllMeds(): List<Medication> {
val medList = mutableListOf<Medication>()
val db = readableDatabase
val query = "SELECT * FROM $TABLE_NAME"
val cursor = db.rawQuery(query, null)
while (cursor.moveToNext()) {
val id = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_ID))
val medpill = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_MEDPILL))
val medtaken = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_MEDTAKEN))
val spannable = SpannableString("Take (" + medpill + ") pill every " + medtaken)
spannable.setSpan(
ForegroundColorSpan(Color.RED),
6, // start
9, // end
Spannable.SPAN_EXCLUSIVE_INCLUSIVE
)
var newText = spannable.toString()
val med = Medication(id, newText)
medList.add(med)
}
cursor.close()
db.close()
return medList
}