我正在使用 CountDownTimer 来显示 View holder 文本视图中的剩余时间。我的代码结构如下:
Class Demo extends ArrayAdapter<ListItem>
{
ListItemHolder holder=new ListItemHolder();
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
holder.tv= (TextView)row.findViewById(R.id.tv_timer);
//Starting the countdown timer
return row;
}
static class ListItemHolder
{
TextView tv;
............
}
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
}
@Override
public void onTick(long millisUntilFinished) {
holder.tv.setText("time");
}
}
}
当我尝试将 onTick 值设置为列表项持有者内的文本视图时,应用程序抛出空指针异常。谁能建议我在这里做错了什么?
提前致谢,
蒂姆森