当前位置: 首页>>代码示例>>Java>>正文


Java Adapter.getCount方法代码示例

本文整理汇总了Java中android.widget.Adapter.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java Adapter.getCount方法的具体用法?Java Adapter.getCount怎么用?Java Adapter.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Adapter的用法示例。


在下文中一共展示了Adapter.getCount方法的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: 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:medalionk,项目名称:simple-share-android,代码行数:22,代码来源:MultiSelectionUtil.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: assertEquals

import android.widget.Adapter; //导入方法依赖的package包/类
public static void assertEquals(Adapter expected, Adapter actual) {
	AndroidTestCase.assertNotNull(actual);
	
	if (expected == null) {
		AndroidTestCase.assertEquals(0, actual.getCount());
		return;
	}
	
	AndroidTestCase.assertEquals(expected.getCount(), actual.getCount());
	
	final int count = expected.getCount();
	for (int i = 0; i < count; i++) {
		AndroidTestCase.assertEquals(
				expected.getItem(i), actual.getItem(i));
	}
}
 
开发者ID:dailystudio,项目名称:devbricks,代码行数:17,代码来源:Asserts.java

示例10: 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

示例11: getItemViewType

import android.widget.Adapter; //导入方法依赖的package包/类
public int getItemViewType(int position) {
    int type = 1;
    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 TYPE_SECTION_HEADER;
        if(position < size) return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;
}
 
开发者ID:wseemann,项目名称:RoMote,代码行数:17,代码来源:SeparatedListAdapter.java

示例12: 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;

        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:Kamshak,项目名称:foursquared,代码行数:17,代码来源:SeparatedListAdapter.java

示例13: setAdapter

import android.widget.Adapter; //导入方法依赖的package包/类
public void setAdapter(Adapter adapter, int initialPosition) {
  if (this.adapter != null) {
    this.adapter.unregisterDataSetObserver(adapterDataObserver);
  }

  Assert.assertNotNull("adapter should not be null", adapter);

  this.adapter = adapter;
  adapterDataCount = adapter.getCount();

  adapterDataObserver = new MyDataSetObserver();
  this.adapter.registerDataSetObserver(adapterDataObserver);
  if (adapterDataCount > 0) {
    setSelection(initialPosition);
  }
}
 
开发者ID:crysehillmes,项目名称:smoothnovelreader,代码行数:17,代码来源:FlipViewController.java

示例14: getSelectedItem

import android.widget.Adapter; //导入方法依赖的package包/类
public Object getSelectedItem() {
    if (mCurrSelectedView != null) {
        int position = mCurrSelectedView.getPosition();
        Adapter adapter = mSpinnerListView.getAdapter();
        if (adapter != null && adapter.getCount() > 0 && position >= 0) {
            return adapter.getItem(position);
        } else {
            return null;
        }
    }
    return null;
}
 
开发者ID:michaelprimez,项目名称:searchablespinner,代码行数:13,代码来源:SearchableSpinner.java

示例15: getItemPosition

import android.widget.Adapter; //导入方法依赖的package包/类
public int getItemPosition(Object item) {
    if (item == null)
        return -1;
    Adapter adapter = mSpinnerListView.getAdapter();
    if (adapter != null) {
        for (int i = 0; i < adapter.getCount(); i++) {
            Object adpItem = adapter.getItem(i);
            if (adpItem != null && adpItem.equals(item)) {
                return i;
            }
        }
    }
    return -1;
}
 
开发者ID:michaelprimez,项目名称:searchablespinner,代码行数:15,代码来源:SearchableSpinner.java


注:本文中的android.widget.Adapter.getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。