天天看點

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);
}