When implementing bindView () for an adapter, can I skip a view?

I implement a custom adapter that iterates over some database items, which in turn access the Android contacts database. The adapter will query the content converter and bind the data from the returned cursor to the view. However, suppose I add a contact to my personal database and then delete it from the Android contact list. The request will fail, and ideally in this case I want to delete this record from the database and try the next one and invalidate the view that I have to bind so that it does not appear on the screen.

I don't see the obvious way to do this from the SDK docs, so I thought I would ask lazyweb!

Another solution is to iterate through the entire private contacts database to instantiate and reduce all bad records, but I find it very expensive.

+3
source share
2 answers

In this case, you cannot cancel the view; you need to return the set of views as invisible.

Use this on the returned view.

view.setVisibility(View.GONE);
+4
source

If the user switches to the contact list application, your application will be paused. If you use a cursor adapter, the adapter will disable the cursor, and if you provided true for the automatic query, the cursor will be updated if you return to your application.

, sql, ? .

+1

Source: https://habr.com/ru/post/1754536/


All Articles