In my program there are a large number of consecutive text elements. It looks like this:
item1
item2
item3
item4
...
And there is a goal to filter out these elements in order to get only those that satisfy the applied filtering at the output:
item3
item4
...
To implement this plan, I have two ways:
1) create a Layout, where each element will be in the form of a TextView:
<TextView android:id="@+id/item1" android:text="@string/item1" /> <TextView android:id="@+id/item2" android:text="@string/item2" /> <TextView android:id="@+id/item3" android:text="@string/item3" /> <TextView android:id="@+id/item4" android:text="@string/item4" /> Then in the code simply hide those that do not satisfy the filtering:
if(blahblah)item1.setVisibility(View.GONE); if(blahblahblah)item2.setVisibility(View.GONE); 2) create a ListView and update its adapter after each filtering:
if(blahblah)items[0]=""; if(blahblahblah)items[1]=""; List<String> finalList = new ArrayList<>(Arrays.asList(items)); finalList.removeAll(Arrays.asList("", null)); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, finalList); listView.setAdapter(adapter); I decided that hiding the View-element requires less performance than updating the whole adapter, so I started writing Layouts. That's just the amount of TextView is really large, no joke, exactly 666 pieces (I did not try, it happened). Could this fact have an even more negative impact on performance?