gpt4 book ai didi

java - ArrayList 无法设置

转载 作者:行者123 更新时间:2023-12-01 13:34:29 24 4
gpt4 key购买 nike

我有一个用于一个 ListView 的适配器,包含这些

    final ViewHolder holder;
if (convertView == null)
{
view = mInflater.inflate(R.layout.auction_list_item, parent , false);
holder = new ViewHolder();
holder.image = (ImageView) view.findViewById(R.id.auction_picture_imageView);
holder.name = (TextView) view.findViewById(R.id.auction_name);
holder.seller = (TextView) view.findViewById(R.id.auction_seller);
holder.time = (TextView) view.findViewById(R.id.auction_time);
holder.duration = (TextView) view.findViewById(R.id.auction_duration);
holder.currentbid = (TextView) view.findViewById(R.id.auction_currentbid);
holder.buynow = (TextView) view.findViewById(R.id.auction_buynow);
holder.layout = (LinearLayout) view.findViewById(R.id.auction_item);
holder.buynowtext = (TextView) view.findViewById(R.id.auction_buynow_textView);

view.setTag(holder);
} else
{
holder = (ViewHolder) view.getTag();
}

String aucend = auctionList.get(position).get(TAG_AUCTIONENDTIME);
Integer timeSecond = Integer.parseInt(aucend.substring(17, 19));
Integer timeMinute = Integer.parseInt(aucend.substring(14, 16));
Integer timeHour = Integer.parseInt(aucend.substring(11, 13));
Integer timeDay = Integer.parseInt(aucend.substring(0, 2));
Integer timeMonth = Integer.parseInt(aucend.substring(3, 5)) - 1;
Integer timeYear = Integer.parseInt(aucend.substring(6, 10));

Time future = new Time();
future.set(timeSecond, timeMinute, timeHour, timeDay, timeMonth, timeYear);
future.normalize(true);
Long futureMillis = future.toMillis(true);

Long interval = futureMillis - nowMillis;

periods.add(interval);
Durations.add(holder.duration);
total = total + 1 ;

我正在尝试插入 holder.duration进入ArrayList<TextView> Durations ,这样我就可以使用一个倒计时器来管理它,使用这个

Durations.add(holder.duration);

这会导致空指针异常。同样的事情也发生在 arraylist 时期。为什么会发生这种情况?

用于存储这些的数组列表在外部初始化

public ArrayList<TextView> Durations;
public ArrayList<Long> periods;

最佳答案

当我没有初始化 arrayList 时,就发生了这种情况。试试这个...

public ArrayList<TextView> Durations = new ArrayList<TextView>();
public ArrayList<Long> periods = new ArrayList<Long>();

关于java - ArrayList<TextView> 无法设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21380357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com