开发者

Android ContentObserver

开发者 https://www.devze.com 2023-01-20 12:33 出处:网络
I have a Cursor \'c\' that generates a ListView. The Content Provider ensures that the ListView gets updated whenever the underlying data changes. However, I want to additionally make a call to anothe

I have a Cursor 'c' that generates a ListView. The Content Provider ensures that the ListView gets updated whenever the underlying data changes. However, I want to additionally make a call to another function to update my Header/Footer views everytime the listv开发者_开发知识库iew is drawn.

How does one implement this with ContentObservers?


public void listenChanges() {
 context.getContentResolver().registerContentObserver(CONTENT_URI, true,
 new MyContentObserver());
}

public class MyContentObserver extends android.database.ContentObserver {

 public MyContentObserver() {
  super(null);
 }

 @Override
 public void onChange(boolean selfChange) {
  super.onChange(selfChange);
  //Do all you need here
 }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消