I am using listview in my program that extends activity. I need to change the color of the clicked list item and strike out the clicked list item.开发者_开发问答 How to do it? any help is really appreciated and thanks in advance...
You'll need to create your custom background drawable for list item.
this links helps: http://developer.android.com/guide/topics/resources/drawable-resource.html
Well you could add a OnItemClickListener to the list view. And when a item is selected. Set the background of that item and use the following code on the textview to strike it out
textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
You need to build the custom adapter for the List. Also in Custom adapter will need to override the function
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View view = super.getView(position, convertView, parent);
view.setBackgroundColor(Color.parseColor("#ffffff"));
return view;
}
This way you can do Text Striking out cell color change on selection and when it comes back after some operation.
Please either put your code snippet of you list and adapter will help you better than.
Vib
精彩评论