Используйте ListView
или RecyclerView
Вот пример
https://uniqsofts.com/android-tutorials/android-listview-example
Опция грубой силы будет заключаться в том, чтобы получить количество вхождений на элемент, а затем отфильтровать этот вывод. Объект collections.Counter
прекрасно работает здесь:
l = [a,b,c,c,c,a,d,e,e,d,d]
c = Counter(l)
# Counter looks like {'a': 2, 'b': 1, 'c': 3...}
l = [item for item in l if c[item]>=3]
Под капотом Counter
действует как словарь, который вы можете построить себе так:
c = {}
for item in l:
# This will check if item is in the dictionary
# if it is, add to current count, if it is not, start at 0
# and add 1
c[item] = c.get(item, 0) + 1
# And the rest of the syntax follows from here
l = [item for item in l if c[item]>=3]
Я бы использовал счетчик из коллекций:
from collections import Counter
count_dict = Counter(l)
[el for el in l if count_dict[el]>2]
Есть ли недостатки с этой опцией?
l = ['a','b','c','c','c','a','d','e','e','d','d']
res = [ e for e in l if l.count(e) >= 3]
#=> ['c', 'c', 'c', 'd', 'd', 'd']
Вы можете использовать collections.Counter
для построения словаря, отображающего значения в счетчики. Затем используйте понимание списка, чтобы отфильтровать счет, превышающий указанное значение.
from collections import Counter
L = list('abcccadeedd')
c = Counter(L)
res = [x for x in L if c[x] >=3]
# ['c', 'c', 'c', 'd', 'd', 'd']