In meiner Anwendung sollte ich ListView
und ArrayAdapter
für einige Liste verwenden. (Ich sollte nicht verwenden RecyclerView
so nicht empfehlen zu mir, es zu verwenden).
So entfernen Sie Artikel von ArrayAdapter?
Ich möchte, wenn der Timer empfangen 0 löschen Sie diesen Artikel.
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();
}
}
});
Ich schreibe diesen Code zum Löschen:
if (remainTime < 0) {
startTimer();
remove(position);
notifyDataSetChanged();
}
aber mich nicht und nicht ein Element gelöscht!
Wie kann ich Artikel vom Adapter entfernen?
nehmen bei Blick https://stackoverflow.com/questions/18444671/remove-item-in-arrayadapterstring-in-listview –
Wo ist() -Methode entfernen? –
@MohdSaquib, ich möchte von Adapter löschen nicht aus Aktivität/Fragment löschen. kannst du mir helfen? – ytyuj