Я динамически настраиваю задний цвет некоторых из ячеек, присутствующих в виде сетки. Проблема заключается в том, что при прокрутке вниз неправильные цвета задаются в качестве фона для некоторых из ячеек. Я перерабатываю вид.Настройка сетки заднего фона
public View getView(final int position, View convertView, ViewGroup parent)
{
ViewHolder holder= new ViewHolder();
if (convertView==null)
{
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(layoutResourceId,parent,false);
holder.textView=(TextView)convertView.findViewById(R.id.text);
convertView.setTag(holder);
}
else
{
holder= (ViewHolder) convertView.getTag();
}
//System.out.println("the position is "+position);
Date i = objects.get(position);
try
{
if (i.getDate() == 1)
{
holder.textview.setBackgroundColor(Color.BLUE);
holder.textView.setText("Mon"+Integer.toString(i.getDate()));
}
else
{
holder.textView.setText(Integer.toString(i.getDate()));
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
Может ли кто-нибудь посоветовать мне, как справиться с этой проблемой?
обновление 1: Я решил вопрос я просто добавил следующее заявление в еще части
if (i.getDate() == 1)
{
holder.textview.setBackgroundColor(Color.BLUE);
holder.textView.setText("Mon"+Integer.toString(i.getDate()));
}
else
{
holder.textView.setText(Integer.toString(i.getDate()));
holder.textview.setBackgroundColor(Color.WHITE);
}
привет, вы можете опубликовать свой модельный класс? или вы можете сказать мне, что такое «объекты» в вашем коде? –