highlight listview items android
- by user1752939
I have listview with custom base adapter. When I populate the list I have to check a boolean in the object I'm populating the listview and if it is true to change the background color of that row.
public View getView(int position, View convertView, ViewGroup parent) {
LoginsList entry = listOfLoginsLists.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.lists_row, null);
}
TextView ListName = (TextView) convertView.findViewById(R.id.tvListName);
ListName.setText(entry.getListName());
TextView ListDescription = (TextView) convertView.findViewById(R.id.tvListDescription);
ListDescription.setText(entry.getListDescription());
Button Send = (Button) convertView.findViewById(R.id.bSend);
Send.setOnClickListener(this);
Send.setTag(entry);
RelativeLayout RelLayout = (RelativeLayout) convertView.findViewById(R.id.layoutListsRow);
RelLayout.setFocusableInTouchMode(false);
RelLayout.setFocusable(false);
RelLayout.setOnClickListener(this);
RelLayout.setTag(entry);
if (entry.isSent()) {
RelLayout.setBackgroundColor(Color.parseColor("#4400FF00"));
}
return convertView;
}
But this code doesn't work right. When I scroll the list view the rows colors get messed up.