In my application i should use ListView
and ArrayAdapter
for show some list. (I shouldn't use RecyclerView
so not recommend to me to use it).
I want when timer receive to 0 delete this item.
public class AuctionTodayListAdapter extends BaseAdapter {
private TextView proName, progressTxt, txtPercent, txtPrice2, txtStartPrice, txtPrice, progressFinishedTxt,
text_view_169622, price, timeView, edtUserName, today_inputPriceTxt, today_basePriceTxt,
txtDate, under10_priceTxt;
private CustomBadge bidCount, offerCount;
private ProgressBar progressBar;
private ImageView GoodPic, userPic, User;
private CountdownView countdownView;
public AuctionTodayListAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<TodayGmodel> objects) {
super(context, resource, objects);
}
@SuppressLint("SetTextI18n")
@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
final TodayGmodel model = (TodayGmodel) datas.get(position);
View view;
if (convertView != null)
view = convertView;
else
view = View.inflate(context, layout, null);
Constants.setFont(parent);
df = new DecimalFormat(",###.##");
Log.e("todayTimer", model.getCalculateEnd() + "");
proName = (TextView) view.findViewById(R.id.text_view_16962);
progressTxt = (TextView) view.findViewById(R.id.progressTxt);
txtPercent = (TextView) view.findViewById(R.id.txtPercent);
txtPrice2 = (TextView) view.findViewById(R.id.txtPrice2);
txtPrice = (TextView) view.findViewById(R.id.txtPrice);
text_view_169622 = (TextView) view.findViewById(R.id.text_view_169622);
txtStartPrice = (TextView) view.findViewById(R.id.txtStartPrice);
countdownView.setOnCountdownIntervalListener(1000, new CountdownView.OnCountdownIntervalListener() {
@Override
public void onInterval(CountdownView cv, long remainTime) {
if (remainTime < 10000 && remainTime > 0) {
winnerLay.setVisibility(View.GONE);
listItem_winnerLay.setVisibility(View.GONE);
listItem_todayUpper10Lay.setVisibility(View.GONE);
listItem_todayPriceLay.setVisibility(View.VISIBLE);
listItem_under10Lay.setVisibility(View.VISIBLE);
under10_priceTxt.setText(df.format(model.getPrice()) + "Dollar");
progressBar.setMax((int) timeInMillis / 1000);
isRunning = true;
countDownTimer = new CountDownTimer(timeInMillis, 100) {
@Override
public void onTick(long millisUntilFinished) {
progressTxt.setText("" + String.valueOf(Math.round(millisUntilFinished * 0.001f)));
progressBar.setProgress(Math.round(millisUntilFinished * 0.001f));
}
@Override
public void onFinish() {
}
}.start();
countDownTimer.start();
}
if (remainTime < 0) {
startTimer();
remove(position);
notifyDataSetChanged();
}
}
});
I write this code for delete :
if (remainTime < 0) {
startTimer();
remove(position);
notifyDataSetChanged();
}
but not work me and not deleted any item!
How can i remove item from adapter?