Java Code Examples for android.widget.BaseAdapter#registerDataSetObserver()

The following examples show how to use android.widget.BaseAdapter#registerDataSetObserver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TurnplateView.java    From Design-Patterns with Apache License 2.0 6 votes vote down vote up
/**
 * 设置适配器
 * @param adapter
 */
public void setAdapter(BaseAdapter adapter) throws NumberOverFlowException {
	this.adapter = adapter;
	if (adapter.getCount() > MAX_NUM) {
		throw new NumberOverFlowException(adapter.getCount());
	}
	adapter.registerDataSetObserver(new DataSetObserver() {
		@Override
		public void onChanged() {
			super.onChanged();
			onDataSetChanged();
		}

		@Override
		public void onInvalidated() {
			super.onInvalidated();
			onDataSetChanged();
		}
	});
	initChild();
}
 
Example 2
Source File: ArticleCollectionActivity.java    From aard2-android with GNU General Public License v3.0 5 votes vote down vote up
public ArticleCollectionPagerAdapter(Application app, BaseAdapter data, ToBlob toBlob, FragmentManager fm) {
    super(fm);
    this.app = app;
    this.data = data;
    this.count = data.getCount();
    this.observer = new DataSetObserver(){
        @Override
        public void onChanged() {
            count = ArticleCollectionPagerAdapter.this.data.getCount();
            notifyDataSetChanged();
        }
    };
    data.registerDataSetObserver(observer);
    this.toBlob = toBlob;
}