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

The following examples show how to use android.widget.BaseAdapter#getCount() . 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: NineGridView.java    From webrtc_android with MIT License 6 votes vote down vote up
public void setAdapter(BaseAdapter adapter) {
    if (adapter != null) {
        if (adapter.getCount() < this.rowNum * this.colNum) {
            throw new IllegalArgumentException("The view count of adapter is less than this gridview's items");
        }
        this.removeAllViews();
        for (int y = 0; y < rowNum; ++y) {
            TableRow row = new TableRow(context);
            row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
            for (int x = 0; x < colNum; ++x) {
                View view = adapter.getView(y * colNum + x, this, row);
                row.addView(view, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
            }
            this.addView(row);
        }
    }
    this.adapter = adapter;
}
 
Example 2
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 3
Source File: ContactsIndexView.java    From PinyinSearchLibrary with Apache License 2.0 6 votes vote down vote up
public void updateContactsList() {
	if (null == mIndexValueLv) {
		return;
	}

	BaseAdapter contactsAdapter = (BaseAdapter) mIndexValueLv.getAdapter();
	if (null != contactsAdapter) {
		contactsAdapter.notifyDataSetChanged();
		if (contactsAdapter.getCount() > 0) {

		} else {

		}

	}
}
 
Example 4
Source File: ContactsOperationView.java    From PinyinSearchLibrary with Apache License 2.0 6 votes vote down vote up
public void refreshContactsLv() {
	if (null == mContactsLv) {
		return;
	}
	
	ViewUtil.hideView(mContactsIndexView);
	
	BaseAdapter contactsAdapter = (BaseAdapter) mContactsLv.getAdapter();
	if (null != contactsAdapter) {
		contactsAdapter.notifyDataSetChanged();
		if (contactsAdapter.getCount() > 0) {
			ViewUtil.showView(mContactsLv);
			ViewUtil.hideView(mSearchResultPromptTv);

		} else {
			ViewUtil.hideView(mContactsLv);
			ViewUtil.showView(mSearchResultPromptTv);

		}
	}
}
 
Example 5
Source File: T9SearchFragment.java    From PinyinSearchLibrary with Apache License 2.0 6 votes vote down vote up
private void refreshT9SearchGv() {
	if (null == mT9SearchGv) {
		return;
	}

	BaseAdapter baseAdapter = (BaseAdapter) mT9SearchGv.getAdapter();
	Log.i(TAG, "getCount"+baseAdapter.getCount()+"");
	if (null != baseAdapter) {
		baseAdapter.notifyDataSetChanged();
		if (baseAdapter.getCount() > 0) {
			ViewUtil.showView(mT9SearchGv);
			ViewUtil.hideView(mSearchResultPromptTv);
		} else {
			ViewUtil.hideView(mT9SearchGv);
			ViewUtil.showView(mSearchResultPromptTv);
		}
	}
}
 
Example 6
Source File: QwertySearchFragment.java    From PinyinSearchLibrary with Apache License 2.0 6 votes vote down vote up
private void refreshQwertySearchGv() {
	if (null == mQwertySearchGv) {
		return;
	}

	BaseAdapter baseAdapter = (BaseAdapter) mQwertySearchGv.getAdapter();
	Log.i(TAG, "getCount"+baseAdapter.getCount()+"");
	if (null != baseAdapter) {
		baseAdapter.notifyDataSetChanged();
		if (baseAdapter.getCount() > 0) {
			ViewUtil.showView(mQwertySearchGv);
			ViewUtil.hideView(mSearchResultPromptTv);
		} else {
			ViewUtil.hideView(mQwertySearchGv);
			ViewUtil.showView(mSearchResultPromptTv);
		}
	}
}
 
Example 7
Source File: SocialGraphItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
	if (adapter == null || position >= adapter.getCount()) {
		return;
	}
	
	User user = (User)adapter.getItem(position);
	if (user == null) {
           return;
       }

	Intent intent = new Intent();
	intent.putExtra("USER", user);
	intent.setClass(parent.getContext(), ProfileActivity.class);
	context.startActivity(intent);
}
 
Example 8
Source File: WallpaperPickerActivity.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@Thunk void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 9
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 10
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 11
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;
}
 
Example 12
Source File: CircularListAdapter.java    From adapter-kit with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a {@linkplain CircularListAdapter}.
 * 
 * @param listAdapter A {@link ListAdapter} that has to behave circular.
 */
public CircularListAdapter(BaseAdapter listAdapter) {
    if(listAdapter == null) {
        throw new IllegalArgumentException("listAdapter cannot be null.");
    }
    
    this.mListAdapter = listAdapter;
    this.mListAdapterCount = listAdapter.getCount();
}