ArrayList<UserDetails> Users; ArrayList<UserDetails> backUp; Context context; LayoutInflater lInflater; private List<UserDetails> filteredModelItemsArray; private ModelFilter filter; ListViewAdapter(ArrayList<UserDetails> Users, Context context) { this.Users = Users; this.backUp = new ArrayList<>(Users); Log.d("myLog ", getCount() + " " + backUp.size()); this.context = context; lInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } 

There are two arrays, the first Users is an array that is subsequently recruited and, under certain conditions, it will be necessary to restore the backUp array, but the problem is that the backUp array cannot be filled, when initialized, the log writes that both the array and the one have zero size, but in getView the Users array works, i.e. size is not equal to zero.

  @Override public View getView(int i, View view, ViewGroup parent) { View viewItem = view; if (view == null) { view = lInflater.inflate(R.layout.list_view_item, parent, false); } UserDetails user = Users.get(i); ((TextView) view.findViewById(R.id.textView)).setText(user.Username); if (user.Online) { ((TextView) view.findViewById(R.id.textView2)).setText("Онлайн"); } else { ((TextView) view.findViewById(R.id.textView2)).setText("Оффлайн"); } return view; } 
  • Please add the getView method code - Ksenia
  • @Ksenia updated - Andrew
  • Add an entry from the logs that is displayed in the adapter's constructor and the code of the getCount() method. - post_zeew
  • I look at the backUp and see that its size = 0, you just created it and everything you expect from it? - PeDuCKA

0