recyclelerview中的Android webview闪烁

时间:2017-01-25 08:47:55

标签: android android-recyclerview recycler-adapter

我有一个RecyclerView,其中嵌入了WebView作为孩子。但我发现每次拨打notifyDatasetChanged(); WebView时,import requests from bs4 import BeautifulSoup import time url = "http://www.olx.ba/pretraga?" kategorija = "kategorija=18" vrsta = "vrsta=samoprodaja" sacijenom = "sacijenom=sacijenom" stranica = 1 links = [] file = open('olx_links.txt', 'w') s = requests.session() while True: url = url + kategorija + "&" + "stranica=" + str(stranica) + "&" + vrsta + "&" + sacijenom headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'} r = s.get(url, headers = headers) page_content = r.content.decode() soup = BeautifulSoup(page_content, "html.parser") articles = soup.find_all(class_="naslov") for link in articles: links.append("%s\n" % link.a["href"]) file.write("%s\n" % link.a["href"]) stranica += 1 if r.status_code != 200: #this part is ineffective s = requests.session() time.sleep(10) print(stranica, len(links), r.status_code, r.cookies) file.close() 都会从空白到内容闪烁。有人帮吗?感谢。

1 个答案:

答案 0 :(得分:3)

调用notifyDatasSetChanged()会导致RecyclerView重建视图的内容。所以这是非常期待的。

不建议在适配器视图中使用WebView,例如RecyclerViewListView