Code example for AbsListView

Methods: setAdapter, setOnItemSelectedListener, setOnScrollListener, setOnTouchListener

0
            // before the item manager was installed. 
            setAdapterOnView(wrapAdapter(itemManager, mWrappedAdapter));
        } else { 
            // Restore the listeners set on the view before the item 
            // manager was installed. 
            mAbsListView.setOnScrollListener(mOnScrollListener);
            mAbsListView.setOnTouchListener(mOnTouchListener);
            mAbsListView.setOnItemSelectedListener(mOnItemSelectedListener);
 
            // Remove wrapper adapter and re-apply the original one 
            setAdapterOnView(mWrappedAdapter);
        } 
 
        mItemManager = itemManager;
        mInstallingManager = false;
    } 
 
    AbsListView getAbsListView() {
        return mAbsListView;
    } 
 
    OnScrollListener getOnScrollListener() {
        return mOnScrollListener;
    } 
 
    void setOnScrollListener(OnScrollListener l) {
        if (mInstallingManager) {
            return; 
        } 
 
        mOnScrollListener = l;
    } 
 
    OnTouchListener getOnTouchListener() {
        return mOnTouchListener;
    } 
 
    void setOnTouchListener(OnTouchListener l) {
        if (mInstallingManager) {
            return; 
        } 
 
        mOnTouchListener = l;
    } 
 
    OnItemSelectedListener getOnItemSelectedListener() {
        return mOnItemSelectedListener;
    } 
 
    void setOnItemSelectedListener(OnItemSelectedListener l) {
        if (mInstallingManager) {
            return; 
        } 
 
        mOnItemSelectedListener = l;
    } 
 
    ListAdapter getWrappedAdapter() {
        return mWrappedAdapter;
    } 
 
    ListAdapter wrapAdapter(ListAdapter adapter) {
        return wrapAdapter(mItemManager, adapter);
    } 
 
    ListAdapter wrapAdapter(ItemManager itemManager, ListAdapter adapter) {
        mWrappedAdapter = adapter;
 
        if (itemManager != null && adapter != null) {
            adapter = new AsyncBaseAdapter(itemManager, (BaseAdapter) adapter);
        } 
 
        return adapter;
    } 
 
    @TargetApi(11) 
    void setAdapterOnView(ListAdapter adapter) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mAbsListView.setAdapter(adapter);
        } else if (mAbsListView instanceof ListView) {
            ((ListView) mAbsListView).setAdapter(adapter);
        } else if (mAbsListView instanceof GridView) {
            ((GridView) mAbsListView).setAdapter(adapter);
        }