I'm doing a to-do list and I wanted add a strikethrough effect after double tapping the ListView
but it gave me an error which says the following.
Cannot find symbol listView.setPaintFlags(listView.getPaintFlags() _ Paint.STRIKE_THRU_TEXT_FLAG)
How Can I solve it?
listView.setOnTouchListener(new View.OnTouchListener() {
private GestureDetector gd = new GestureDetector(MainActivity.this,new GestureDetector.SimpleOnGestureListener() {
public boolean onDoubleTap(MotionEvent e) {
ListView listView = (ListView) findViewById(R.id.listView);
listView.setPaintFlags(listView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
return true;
}
});
@Override
public boolean onTouch(View view, MotionEvent event) {
return gd.onTouchEvent(event);
}
});
}
I do not think the ListView
has the method which provides the strikethrough feature on its items. I think the TextView
inside an item of your ListView
has the attribute which should work like the following.
TextView tv = (TextView) v.findViewById(android.R.id.text1);
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
You might also consider implementing your custom adapter to get the reference of the TextView
and strikethrough the view using the code above.