Search code examples
androidlistviewstrikethrough

Using strikethrough in ListView using ArrayAdapter


I have added elements in ListView through database using array adapter. Here I want the element to have a strikethrough. How can I do this?

Here is the code I am using:

String q4 = "select * from todolist;";
Cursor d = database.rawQuery(q4, null);
if(d != null && d.moveToFirst()) {
    do {
        String element =d.getString(d.getColumnIndex("elist"));
        al.add(element);
        ArrayAdapter ad = new ArrayAdapter(getContext(),android.R.layout.simple_list_item_1,al);
        list.setAdapter(ad);
    } while (d.moveToNext());
}

Solution

  • For anyone looking for an answer, Array Adapter cannot alter the view of its contents. Using Base adapter is the best option.