码迷,mamicode.com
首页 > 其他好文 > 详细

adapter

时间:2014-05-26 15:45:34      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:android   style   c   class   blog   code   

1、android widget基础适配器  Adapter

bubuko.com,布布扣
public interface Adapter {
    注册数据集观察者,以便监听数据变动。
    void registerDataSetObserver(DataSetObserver observer);

    注销数据集观察者
    void unregisterDataSetObserver(DataSetObserver observer);

    获取数据集里数据项的数量
    int getCount();   
    
    获取指定position位置数据项
    Object getItem(int position);
    
    获取数据项的ID
    long getItemId(int position);
    
    数据集是否固定
    boolean hasStableIds();
    
    从数据集指定位置获取一个VIEW用来显示数据,你既可以通过创建一个VIEW也可以通过XML资源文件来inflate。
    当你通过XML资源文件创建时,默认的父VIEW给这个VIEW提供默认的LAYOUT参数,当然你也可以通过
    android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)
    来指定一个父view。
    position:指定的位置
    convertView:为了重复使用VIEW,当原来的VIEW和现在要使用的VIEW类型一致时,不需要转换,只需要更改内容就可以, 
                当类型不一样时,需要重新创建一个新类型的VIEW以便显示数据。
    parent:指定的父VIEW。   
    View getView(int position, View convertView, ViewGroup parent);

    static final int IGNORE_ITEM_VIEW_TYPE = AdapterView.ITEM_VIEW_TYPE_IGNORE;

    获取指定位置数据项显示VIEW的类型
    int getItemViewType(int position);
    
    获取总共VIEW的类型数量
    int getViewTypeCount();
    
    static final int NO_SELECTION = Integer.MIN_VALUE;
 
    判断是否为空
    boolean isEmpty();
}
bubuko.com,布布扣

2、SpinnerAdapter

bubuko.com,布布扣
public interface SpinnerAdapter extends Adapter {
    /**
     * <p>Get a {@link android.view.View} that displays in the drop down popup
     * the data at the specified position in the data set.</p>
     *
     * @param position      index of the item whose view we want.
     * @param convertView   the old view to reuse, if possible. Note: You should
     *        check that this view is non-null and of an appropriate type before
     *        using. If it is not possible to convert this view to display the
     *        correct data, this method can create a new view.
     * @param parent the parent that this view will eventually be attached to
     * @return a {@link android.view.View} corresponding to the data at the
     *         specified position.
     */
    public View getDropDownView(int position, View convertView, ViewGroup parent);
}
bubuko.com,布布扣

3、ListAdapter

bubuko.com,布布扣
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) 
     */
    public boolean areAllItemsEnabled();

    /**
     * Returns true if the item at the specified position is not a separator.
     * (A separator is a non-selectable, non-clickable item).
     * 
     * The result is unspecified if position is invalid. An {@link ArrayIndexOutOfBoundsException}
     * should be thrown in that case for fast failure.
     *
     * @param position Index of the item
     * 
     * @return True if the item is not a separator
     * 
     * @see #areAllItemsEnabled() 
     */
    boolean isEnabled(int position);
}
bubuko.com,布布扣

adapter,布布扣,bubuko.com

adapter

标签:android   style   c   class   blog   code   

原文地址:http://www.cnblogs.com/try-catch/p/3746060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!