天天看点

Android之Adapter系列之ListAdapter接口

<pre name="code" class="java">ListAdapter同样是一个接口,比较简单,仅仅继承Atapter,并添加了两个方法

源码路径:framework\base\core\java\android\widget\ListAdapter.java

package android.widget;

/**
 * ListAdapter继承了Adapter,是ListView数据和显示的桥梁,通常要
 * 显示的数据来自于Cursor。但是这不是必须的。ListView能够显示任
 * 何有ListAdapter包装的数据。
 */
public interface ListAdapter extends Adapter {

    /**
     * Indicates whether all the items in this adapter are enabled. If the
     * value returned by this method changes over time, there is no guarantee
     * it will take effect.  If true, it means all items are selectable and
     * clickable (there is no separator.)
     * 
     * @return True if all items are enabled, false otherwise.
     * 
     * @see #isEnabled(int) 
     */
	 
    /**
     * 用来判断Adapter中的所有items是否是enables状态,如果该方法返回值随时间而变化. 
     * 那么就无法保证该结果有效,如果返回true,那么表明Adapter中的所有items是可以选中
     * 并且可以点击(没有例外)
     */
    public boolean areAllItemsEnabled();

   /**
     * 除了特殊情况(不可点击和不可选择的item)item外,返回true
     * 
     * 如果指定的position是非法的,那么返回的结果是不特定的
	 * An {@link ArrayIndexOutOfBoundsException}
     * should be thrown in that case for fast failure.
     */
    boolean isEnabled(int position);
}