當前位置: 首頁>>代碼示例>>Java>>正文


Java Adapter類代碼示例

本文整理匯總了Java中android.widget.Adapter的典型用法代碼示例。如果您正苦於以下問題:Java Adapter類的具體用法?Java Adapter怎麽用?Java Adapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Adapter類屬於android.widget包,在下文中一共展示了Adapter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getView

import android.widget.Adapter; //導入依賴的package包/類
@Override
public View getView(int position, final View convertView, final ViewGroup parent)
{
    
    int sectionNum = 0;
    
    for (final String sectionName : sectionMap.keySet())
    {
        final Adapter adapter = sectionMap.get(sectionName);
        
        final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
        
        if (position == 0 && hasSectionHeader)
            return sectionAdapter.getView(sectionNum, convertView, parent);
        
        if (position < size)
            return adapter.getView(position - 1, convertView, parent);
        
        position -= size;
        sectionNum++;
    }
    
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:25,代碼來源:SectionListAdapter.java

示例2: isScrolledAtEnd

import android.widget.Adapter; //導入依賴的package包/類
/**
 */
@Override
public boolean isScrolledAtEnd() {
	final int childCount = mScrollableView.getChildCount();
	if (childCount == 0) {
		return true;
	}

	final Adapter adapter = mScrollableView.getAdapter();
	final int adapterCount = adapter != null ? adapter.getCount() : 0;
	if (adapterCount == 0) {
		return true;
	}

	final int lastVisiblePos = mScrollableView.getLastVisiblePosition();
	if (lastVisiblePos == (adapterCount - 1)) {
		final View lastChild = mScrollableView.getChildAt(childCount - 1);
		return lastChild != null && lastChild.getBottom() == mScrollableView.getHeight();
	}
	return false;
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:23,代碼來源:ScrollableWrapper.java

示例3: isFirstItemVisible

import android.widget.Adapter; //導入依賴的package包/類
private boolean isFirstItemVisible() {
	final Adapter adapter = mRefreshableView.getAdapter();

	if (null == adapter || adapter.isEmpty()) {
		if (DEBUG) {
			Log.d(LOG_TAG, "isFirstItemVisible. Empty View.");
		}
		return true;

	} else {

		/**
		 * This check should really just be:
		 * mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView
		 * internally use a HeaderView which messes the positions up. For
		 * now we'll just add one to account for it and rely on the inner
		 * condition which checks getTop().
		 */
		if (mRefreshableView.getFirstVisiblePosition() <= 1) {
			final View firstVisibleChild = mRefreshableView.getChildAt(0);
			if (firstVisibleChild != null) {
				return firstVisibleChild.getTop() >= mRefreshableView.getTop();
			}
		}
	}

	return false;
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:29,代碼來源:PullToRefreshAdapterViewBase.java

示例4: setSelectedItem

import android.widget.Adapter; //導入依賴的package包/類
public void setSelectedItem(int position) {
    Adapter adapter = mSpinnerListView.getAdapter();
    if (adapter instanceof ISpinnerSelectedView) {
        View selectedView = ((ISpinnerSelectedView) adapter).getSelectedView(position);
        mCurrSelectedView = new SelectedView(selectedView, position, selectedView.getId());
        mSpinnerListView.setSelection(position);
    } else {
        TextView textView = new TextView(mContext);
        textView.setText(mRevealEmptyText);
        mCurrSelectedView = new SelectedView(textView, -1, 0);
        mRevealItem.addView(textView);
    }
    if (mCurrSelectedView == null) {
        if (mOnItemSelected != null)
            mOnItemSelected.onNothingSelected();
    } else if (mCurrSelectedView != null) {
        mRevealItem.removeAllViews();
        mSpinnerListView.removeViewInLayout(mCurrSelectedView.getView());
        mRevealItem.addView(mCurrSelectedView.getView());
        ((BaseAdapter) mSpinnerListView.getAdapter()).notifyDataSetChanged();
        if (mOnItemSelected != null)
            mOnItemSelected.onItemSelected(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId());
    }
    hideEdit();
}
 
開發者ID:michaelprimez,項目名稱:searchablespinner,代碼行數:26,代碼來源:SearchableSpinner.java

示例5: setAdapter

import android.widget.Adapter; //導入依賴的package包/類
@Override
public void setAdapter(Adapter adapter) {

	//  release previous adapter's bitmaps
	if (null!=mAdapter && adapter!=mAdapter) {
		if (adapter instanceof MuPDFPageAdapter){
			((MuPDFPageAdapter) adapter).releaseBitmaps();
		}
	}


	mAdapter = adapter;
	//mChildViews.clear();
	//removeAllViewsInLayout();
	requestLayout();
}
 
開發者ID:do-android,項目名稱:do_PDFView,代碼行數:17,代碼來源:ReaderView.java

示例6: getItemViewType

import android.widget.Adapter; //導入依賴的package包/類
@Override
public int getItemViewType(int position)
{
    int type = 1;
    
    for (final Object section : sectionMap.keySet())
    {
        
        final Adapter adapter = sectionMap.get(section);
        final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
        
        if (position == 0 && hasSectionHeader)
            return TYPE_SECTION_HEADER;
        
        if (position < size)
            return type + adapter.getItemViewType(position - 1);
        
        position -= size;
        type += adapter.getViewTypeCount();
    }
    
    return -1;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:24,代碼來源:SectionListAdapter.java

示例7: getItem

import android.widget.Adapter; //導入依賴的package包/類
@Override
public Object getItem(int position)
{
    
    for (final Map.Entry<String,Adapter> entry : sectionMap.entrySet())
    {
        final Adapter adapter = entry.getValue();
        
        final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
        
        if (position == 0 && hasSectionHeader)
            return entry.getKey();
        
        if (position < size)
            return adapter.getItem(position - 1);
        
        position -= size;
    }
    
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:22,代碼來源:SectionListAdapter.java

示例8: getAdapter

import android.widget.Adapter; //導入依賴的package包/類
public Adapter getAdapter(int position)
{
    for (final Adapter adapter : sectionMap.values())
    {
        final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
        
        if (position == 0 && hasSectionHeader)
            return null;
        
        if (position < size)
            return adapter;
        
        position -= size;
    }
    
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:18,代碼來源:SectionListAdapter.java

示例9: indexOf

import android.widget.Adapter; //導入依賴的package包/類
public int indexOf(Object object)
{
    int idx = 0;
    for (final Map.Entry<String,Adapter> entry : sectionMap.entrySet())
    {
        final Adapter adapter = entry.getValue();
        
        if (object.equals(entry.getKey()))
            return idx;
        
        for (int i = 0; i < adapter.getCount(); i++)
        {
            if (object.equals(adapter.getItem(i)))
                return idx + (hasSectionHeader ? 1 : 0) + i;
        }
        
        idx += adapter.getCount() + (hasSectionHeader ? 1 : 0);
    }
    return -1;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:21,代碼來源:SectionListAdapter.java

示例10: onNewLog

import android.widget.Adapter; //導入依賴的package包/類
@Override
public void onNewLog(String logPath) throws RemoteException {
    File file = new File(logPath);
    if(file.exists() && file.isFile()) {
        try {
            final BlockInfoEx blockInfoEx = BlockInfoEx.newInstance(file);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mBlockInfoEntries.add(0, blockInfoEx);
                    while (mBlockInfoEntries.size() > sMaxStoreBlockCount) {
                        mBlockInfoEntries.remove(mBlockInfoEntries.size() - 1);
                    }
                    Adapter adapter = mListView.getAdapter();
                    if (adapter instanceof BlockListAdapter) {
                        ((BlockListAdapter) adapter).notifyDataSetChanged();
                    }
                }
            });
        } catch (Exception e) {
            Log.e(TAG, "block info parse failed:" + e);
        }
    }
}
 
開發者ID:seiginonakama,項目名稱:BlockCanaryEx,代碼行數:25,代碼來源:DisplayActivity.java

示例11: withAdaptedData

import android.widget.Adapter; //導入依賴的package包/類
public static Matcher<View> withAdaptedData(final Matcher<String> dataMatcher) {
    return new TypeSafeMatcher<View>() {

        @Override
        public void describeTo(Description description) {
            description.appendText("with class name: ");
            dataMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            if (!(view instanceof AdapterView)) {
                return false;
            }
            @SuppressWarnings("rawtypes")
            Adapter adapter = ((AdapterView) view).getAdapter();
            for (int i = 0; i < adapter.getCount(); i++) {
                if (dataMatcher.matches(adapter.getItem(i))) {
                    return true;
                }
            }
            return false;
        }
    };
}
 
開發者ID:mvescovo,項目名稱:item-reaper,代碼行數:26,代碼來源:CustomMatchers.java

示例12: rememberSyncState

import android.widget.Adapter; //導入依賴的package包/類
void rememberSyncState() {
	if (getChildCount() > 0) {
		this.mNeedSync = true;
		this.mSyncHeight = this.mLayoutHeight;
		View localView;
		if (this.mSelectedPosition >= 0) {
			localView = getChildAt(this.mSelectedPosition - this.mFirstPosition);
			this.mSyncRowId = this.mNextSelectedRowId;
			this.mSyncPosition = this.mNextSelectedPosition;
			if (localView != null)
				this.mSpecificTop = localView.getTop();
			this.mSyncMode = 0;
		} else {
			localView = getChildAt(0);
			Adapter localAdapter = getAdapter();
			if ((this.mFirstPosition >= 0) && (this.mFirstPosition < localAdapter.getCount()))
				this.mSyncRowId = localAdapter.getItemId(this.mFirstPosition);
			else
				this.mSyncRowId = -1L;
			this.mSyncPosition = this.mFirstPosition;
			if (localView != null)
				this.mSpecificTop = localView.getTop();
			this.mSyncMode = 1;
		}
	}
}
 
開發者ID:Evan-Galvin,項目名稱:FreeStreams-TVLauncher,代碼行數:27,代碼來源:AdapterView.java

示例13: tryRestoreInstanceState

import android.widget.Adapter; //導入依賴的package包/類
private void tryRestoreInstanceState(HashSet<Long> idsToCheckOnRestore) {
    if (idsToCheckOnRestore == null || mListView.getAdapter() == null) {
        return;
    }
    boolean idsFound = false;
    Adapter adapter = mListView.getAdapter();
    for (int pos = adapter.getCount() - 1; pos >= 0; pos--) {
        if (idsToCheckOnRestore.contains(adapter.getItemId(pos))) {
            idsFound = true;
            if (mItemsToCheck == null) {
                mItemsToCheck = new HashSet<Pair<Integer, Long>>();
            }
            mItemsToCheck.add(new Pair<Integer, Long>(pos, adapter.getItemId(pos)));
        }
    }
    if (idsFound) {
        // We found some IDs that were checked. Let's now restore the multi-selection
        // state.
        mActionMode = mActivity.startSupportActionMode(mCallbacks);
    }
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:22,代碼來源:MultiSelectionUtil.java

示例14: isLastItemVisible

import android.widget.Adapter; //導入依賴的package包/類
private boolean isLastItemVisible() {
    Adapter adapter = ((AbsListView) this.mRefreshableView).getAdapter();
    if (adapter == null || adapter.isEmpty()) {
        return true;
    }
    int lastItemPosition = ((AbsListView) this.mRefreshableView).getCount() - 1;
    int lastVisiblePosition = ((AbsListView) this.mRefreshableView).getLastVisiblePosition();
    if (lastVisiblePosition >= lastItemPosition - 1) {
        View lastVisibleChild = ((AbsListView) this.mRefreshableView).getChildAt
                (lastVisiblePosition - ((AbsListView) this.mRefreshableView)
                        .getFirstVisiblePosition());
        if (lastVisibleChild != null) {
            return lastVisibleChild.getBottom() <= ((AbsListView) this.mRefreshableView)
                    .getBottom();
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:PullToRefreshAdapterViewBase.java

示例15: getView

import android.widget.Adapter; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    int sectionnum = 0;
    for(Object section : this.sections.keySet()) {
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if(position == 0) return headers.getView(sectionnum, convertView, parent);
        if(position < size) return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}
 
開發者ID:wseemann,項目名稱:RoMote,代碼行數:18,代碼來源:SeparatedListAdapter.java


注:本文中的android.widget.Adapter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。