最初にリストビューを読み込むと正しいアイテムが表示されます。戻って再び読み込むと、アイテム全体が再び繰り返されます。繰り返しますが、私が戻って同じものをロードすると、エントリは再び繰り返されます。Androidリストビューアイテムが繰り返されます
例:最初は4つの項目、2番目の項目は8番目の項目、3番目の項目は12番目の項目などです。
以下は私のcustomarrayadapter's
getView()
の方法です。
パブリッククラスCustomArrayAdapterHistoryはArrayAdapter {
ArrayList<RequestHistory> historyList = new ArrayList<>();
private Context context;
public CustomArrayAdapterHistory(Context context, int textViewResourceId, ArrayList<RequestHistory> objects) {
super(context, textViewResourceId, objects);
historyList = objects;
this.context=context;
}
@Override
public int getCount() {
return super.getCount();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.request_history_items, null);
TextView textView1 = (TextView) v.findViewById(R.id.textView1);
TextView textView2 = (TextView) v.findViewById(R.id.textView2);
TextView textView3 = (TextView) v.findViewById(R.id.textView3);
ImageView imageView= (ImageView) v.findViewById(R.id.imageView);
TextView date= (TextView) v.findViewById(R.id.date);
Log.e("Date","....."+historyList.get(position).getDate());
date.setText(historyList.get(position).getDate());
if(historyList.get(position).getserviceName()!="null")
if(historyList.get(position).getserviceName()!="")
textView1.setText(historyList.get(position).getserviceName());
if(historyList.get(position).getreplyNote().equals("")){
textView3.setVisibility(View.INVISIBLE);
}
else {
textView3.setText("Reply: " + historyList.get(position).getreplyNote());
}
textView2.setText("Booking Details: " + historyList.get(position).getBookingdetails());
if(historyList.get(position).getStatus().equals("0")){
imageView.setBackgroundResource(R.drawable.pending);
}
else if(historyList.get(position).getStatus().equals("1")){
Log.e("STATUS ID","....."+historyList.get(position).getStatus());
imageView.setBackgroundResource(R.drawable.cross);
}
else if(historyList.get(position).getStatus().equals("2")){
imageView.setBackgroundResource(R.drawable.tick);
}
return v;
この問題を解決するために私を助けてくださいを拡張します。
古いリスト –
を削除 – Vickyexpert
があなたのコンストラクタを投稿ListViewコントロールするアダプタを設定するためのロジックを示して、私はあなた 'historyList'初期どのように見てみたいです。私は問題が最初に –