我正在寻找在RecyclerView中更改视图可见性的方法。
我试图将# opening file and returning raw data
file = input('Data file: ')
with open(file) as t:
nums = t.readlines()
t.close()
print(f'Raw data: {nums}')
# counting pairs in raw data
count = 0
for i in nums:
count += 1
print(f'Count of number pairs: {count}')
# removing carriage returns and hyphens
one = []
for i in nums:
one.append(i.rsplit())
new = []
for i in one:
for a in i:
new.append(a.split('-'))
print(f'Data sets: {new}')
# finding the range of the final list
my_list = []
for i in new:
for e in i:
my_list.append(int(e))
ran = max(my_list) + 1
print(f'Range of final list: {ran}')
# setting up the product list
rcount = count-1
product = list(range(ran))
print(f'Unchanged product: {product}')
for i in product:
for e in range(rcount):
if product[int(new[e][0])] < product[int(new[e][1])]:
product[int(new[e][1])] = product[int(new[e][0])]
else:
product[int(new[e][0])] = product[int(new[e][1])]
print(f'Resulting product: {product}')
添加到我的android:animateLayoutChanges="true"
(RecyclerViews项目的根目录)中,并以编程方式更改其子项的可见性。
效果很好,但是前几项很奇怪-我的意思是它们完全消失并再次显示,而不是仅对一个视图的可见性进行动画处理。其他的都很好。
有什么解决办法吗?您是否需要其他信息? 感谢您的帮助!
答案 0 :(得分:0)
您可以为ÌtemAnimator
设置默认的RecyclerView
your_recycler_view.setItemAnimator(new DefaultItemAnimator());