Code example for ListAdapter

Methods: getCountisEnabled

0
    public int getViewTypeCount() { 
        return mAdapter.getViewTypeCount();
    } 
 
    private boolean isItem(int position) {
        return position < mAdapter.getCount();
    } 
 
    /** {@inheritDoc} */ 
    public View getView(int position, View convertView, ViewGroup parent) {
        if (isItem(position)) {
            return mAdapter.getView(position, convertView, parent);
        } else if (hasError()) { 
            LayoutInflater inflater = getLayoutInflater(parent);
            return newErrorView(inflater, parent);
        } else if (hasMore()) { 
            LayoutInflater inflater = getLayoutInflater(parent);
            return newLoadingView(inflater, parent);
        } else { 
            throw new IndexOutOfBoundsException();
        } 
    } 
 
    /** 
     * Creates a view that is shown when there is an error. 
     *  
     * @param inflater a layout inflater. 
     * @param parent the parent view. 
     * @return a new error view. 
     * @see LayoutInflater#inflate(int, ViewGroup, boolean) 
     */ 
    protected abstract View newErrorView(LayoutInflater inflater, ViewGroup parent);
 
    /** 
     * Creates a view that is shown when more items can be loaded. 
     *  
     * @param inflater a layout inflater. 
     * @param parent the parent view. 
     * @return a new loading view. 
     * @see LayoutInflater#inflate(int, ViewGroup, boolean) 
     */ 
    protected abstract View newLoadingView(LayoutInflater inflater, ViewGroup parent);
 
    /** {@inheritDoc} */ 
    public Object getItem(int position) {
        if (isItem(position)) {
            return mAdapter.getItem(position);
        } else { 
            return null; 
        } 
    } 
 
    /** {@inheritDoc} */ 
    public long getItemId(int position) {
        if (isItem(position)) {
            return mAdapter.getItemId(position);
        } else { 
            return AdapterView.INVALID_ROW_ID;
        } 
    } 
 
    /** {@inheritDoc} */ 
    public boolean hasStableIds() { 
        return mAdapter.hasStableIds();
    } 
 
    /** {@inheritDoc} */ 
    public final boolean isEmpty() { 
        // This method must not be overridden to ensure consistency 
        return getCount() == 0; 
    } 
 
    /** {@inheritDoc} */ 
    public void registerDataSetObserver(DataSetObserver observer) {
        mAdapter.registerDataSetObserver(observer);
    } 
 
    /** {@inheritDoc} */ 
    public void unregisterDataSetObserver(DataSetObserver observer) {
        mAdapter.unregisterDataSetObserver(observer);
    } 
 
    /** {@inheritDoc} */ 
    public boolean areAllItemsEnabled() { 
        // The loading view cannot be clicked. 
        // See also: http://code.google.com/p/android/issues/detail?id=8914 
        return false; 
    } 
 
    /** {@inheritDoc} */ 
    public boolean isEnabled(int position) {
        if (isItem(position)) {
            return mAdapter.isEnabled(position);
        } else { 
            return false; 
        } 
    }