想要在列表视图中的文本视图中设置罢工
我有 ListView,其中必须使用自定义布局显示 TextView。我正在显示带有截止日期的任务列表。现在我想对 TextView 的文本设置罢工效果,该文本的截止日期在当前日期之后,我可以设置,但当我滚动视图时,它的更改意味着它在今天的日期或明天的日期任务上设置。
这是我的代码:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
Date due_date = new Date(due_date_long);
if (convertView == null) {
view = mInflater.inflate(R.layout.tasks_row2, null);
ViewHolder holder = new ViewHolder();
holder.text1 = (TextView) view.findViewById(R.id.label);//Task Title
view.setTag(holder);
}else{
view = convertView;
}
ViewHolder holder = (ViewHolder) view.getTag();
holder.text1.setText(task_title);
//if(YESTERDAY.equals(task_date))
if(cur_date.after(due_date))
holder.text1.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
return view;
}
I have ListView in which I have to display TextView with custom layout. I'm displaying the list of task with due date. Now I want to set strike effect on text of TextView which have due date was after with current date I am able to set but as I have scroll the view it's change means its set on today's date or tomorrow's date task.
here is my code :
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
Date due_date = new Date(due_date_long);
if (convertView == null) {
view = mInflater.inflate(R.layout.tasks_row2, null);
ViewHolder holder = new ViewHolder();
holder.text1 = (TextView) view.findViewById(R.id.label);//Task Title
view.setTag(holder);
}else{
view = convertView;
}
ViewHolder holder = (ViewHolder) view.getTag();
holder.text1.setText(task_title);
//if(YESTERDAY.equals(task_date))
if(cur_date.after(due_date))
holder.text1.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
return view;
}
这是非常常见的问题,您必须编写此行的 else 部分
This is very common problem you will have to write the else part of this line