我有3个页面的viewPager()
,它有一个recyclerView
,每个页面都有三个不同的适配器,我想要类似的东西,例如当用户单击第一页中的适配器项时,它将添加到数据库中,第二个适配器从相同的数组中获取其数组列表数据库,但它在应用程序重启后显示在第二页的适配器中,因此问题是如何在不重启的情况下更新第二页的适配器。
A regular ListView
can use a CursorAdapter
which provides some of the functions you need. Alas, there is no existing CursorAdapter
class that extends RecyclerView.Adapter
.
The quickest solution would be to use RecyclerViewCursorAdapter
on GitHub.
Then it would work something like this:
getItem()
. Note that your fragment could be null depending on what pages the ViewPager
has/hasn't created. Cursor
to be used by the adapter (with the same query as before). When the adapter receives the new Cursor
it will update the RecyclerView
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.