Sam
Sam

Reputation: 58

Highlight items of a listview without using onTouch or onItemClick

I am using a default array adapter to display my listview.

How do I highlight specific rows from my listview without touching anything i.e. without using onTouch() or onItemClick() (Just by using a code!) ?

Upvotes: 0

Views: 91

Answers (1)

Vilen
Vilen

Reputation: 5061

I guess the way you should do it is use custom adapter and in getVew function highlight the row you needed

e.g.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View row = convertView;
    final Holder holder;
    if (row == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
... 
if(position==thePositionYouNeed)
row.setBackgroundColor(color) 

Upvotes: 1

Related Questions