I have this code in my getView of BaseAdapter class:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View v;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.listview_item, parent, false);
} else {
v = convertView;
}
LinearLayout mLayout = v.findViewById(R.id.layout_list_item);
if (!mList.get(position).isOperative()) {
mLayout.setBackgroundResource(R.drawable.list_item_background_inactive);
} else {
mLayout.setBackgroundResource(R.drawable.list_item_background_active);
}
TextView mTextOne = v.findViewById(R.id.text_one);
TextView mTextTwo = v.findViewById(R.id.text_two);
mTextOne.setText(mList.get(position).getPropertyOne());
mTextTwo.setText(mList.get(position).getPropertyTwo());
return v;
}
The background was applied properly at the begin, but if I scroll, I'm losing the initial setting.
Any ideas?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire