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


Java HeaderViewListAdapter.getHeadersCount方法代码示例

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


在下文中一共展示了HeaderViewListAdapter.getHeadersCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onScroll

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
		int visibleItemCount, int totalItemCount)
{		
	if (firstVisibleItem < this.topVisibleItem - DISTANCE_TO_HIDE_ACTIONBAR)
	{
		setActionbarVisibility(true);
		this.topVisibleItem = firstVisibleItem;
	}
	else if (firstVisibleItem > this.topVisibleItem + DISTANCE_TO_HIDE_ACTIONBAR)
	{
		setActionbarVisibility(false);
		this.topVisibleItem = firstVisibleItem;
	}
	
	ListAdapter adapter = view.getAdapter();
	if (adapter instanceof HeaderViewListAdapter)
	{
		HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter;
		if (headerViewListAdapter.getWrappedAdapter() instanceof FileCardAdapter)
		{
			int startPrefetch = firstVisibleItem + visibleItemCount-headerViewListAdapter.getHeadersCount();
			((FileCardAdapter) headerViewListAdapter.getWrappedAdapter()).prefetchImages(startPrefetch, visibleItemCount);
		}
	}
}
 
开发者ID:mick88,项目名称:filemanager,代码行数:27,代码来源:FolderFragment.java

示例2: onItemClick

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
@Override
public final void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
	PinnedHeaderAdapter adapter = null;
	int headerCount = 0;
	int footerCount = 0;
	// 如果设置过header view,注意会有一个包装的adapter返回,并不是原来设置的adapter
	if (adapterView.getAdapter() instanceof HeaderViewListAdapter) {
		HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
		headerCount = wrapperAdapter.getHeadersCount();
		footerCount = wrapperAdapter.getFootersCount();
		if (wrapperAdapter.getWrappedAdapter() instanceof PinnedHeaderAdapter)
			adapter = (PinnedHeaderAdapter) wrapperAdapter.getWrappedAdapter();
	} else {
		if (adapterView.getAdapter() instanceof PinnedHeaderAdapter)
			adapter = (PinnedHeaderAdapter) adapterView.getAdapter();
	}
	if (adapter == null)
		return;
	// 如果点击的是header view,则不响应
	if (position < headerCount) {
		onHeaderClick(adapterView, position);
		return;
	}
	// 如果点击的是footer view,也不响应
	if (footerCount > 0 && position >= adapterView.getAdapter().getCount() - footerCount) {
		onFooterClick(adapterView, position - (adapterView.getAdapter().getCount() - footerCount));
		return;
	}
	int adjustPosition = position - headerCount;
	int section = adapter.getSectionForPosition(adjustPosition);
	if (adapter.isSectionHeader(adjustPosition)) {
		onSectionHeaderClick(adapterView, section, id);
	} else {
		int positionInSection = adapter.getPositionInSectionForPosition(adjustPosition);
		onItemClick(adapterView, section, positionInSection, id);
	}
}
 
开发者ID:houjinyun,项目名称:PinnedHeaderView,代码行数:38,代码来源:PinnedHeaderListView.java

示例3: onItemLongClick

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
@Override
public final boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
	PinnedHeaderAdapter adapter = null;
	int headerCount = 0;
	int footerCount = 0;
	// 如果设置过header view,注意会有一个包装的adapter返回,并不是原来设置的adapter
	if (parent.getAdapter() instanceof HeaderViewListAdapter) {
		HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) parent.getAdapter();
		headerCount = wrapperAdapter.getHeadersCount();
		footerCount = wrapperAdapter.getFootersCount();
		if (wrapperAdapter.getWrappedAdapter() instanceof PinnedHeaderAdapter)
			adapter = (PinnedHeaderAdapter) wrapperAdapter.getWrappedAdapter();
	} else {
		if (parent.getAdapter() instanceof PinnedHeaderAdapter)
			adapter = (PinnedHeaderAdapter) parent.getAdapter();
	}
	if (adapter == null)
		return false;
	// 如果点击的是header view,则不响应
	if (position < headerCount) {
		onHeaderLongClick(parent, position);
		return false;
	}
	// 如果点击的是footer view,也不响应
	if (footerCount > 0 && position >= parent.getAdapter().getCount() - footerCount) {
		onFooterLongClick(parent, position - (parent.getAdapter().getCount() - footerCount));
		return false;
	}

	int adjustPosition = position - headerCount;
	int section = adapter.getSectionForPosition(adjustPosition);
	if (adapter.isSectionHeader(adjustPosition)) {
		onSectionHeaderLongClick(parent, section, id);
	} else {
		int positionInSection = adapter.getPositionInSectionForPosition(adjustPosition);
		onItemLongClick(parent, section, positionInSection, id);
	}
	return false;
}
 
开发者ID:houjinyun,项目名称:PinnedHeaderView,代码行数:40,代码来源:PinnedHeaderListView.java

示例4: getHeaderViews

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
public List<View> getHeaderViews() {
  HeaderViewListAdapter adapter = (HeaderViewListAdapter) realListView.getAdapter();
  ArrayList<View> headerViews = new ArrayList<View>();
  int headersCount = adapter.getHeadersCount();
  for (int i = 0; i < headersCount; i++) {
    headerViews.add(adapter.getView(i, null, realListView));
  }
  return headerViews;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:10,代码来源:ShadowListView.java

示例5: getFooterViews

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
public List<View> getFooterViews() {
  HeaderViewListAdapter adapter = (HeaderViewListAdapter) realListView.getAdapter();
  ArrayList<View> footerViews = new ArrayList<View>();
  int offset = adapter.getHeadersCount() + adapter.getCount() - adapter.getFootersCount();
  int itemCount = adapter.getCount();
  for (int i = offset; i < itemCount; i++) {
    footerViews.add(adapter.getView(i, null, realListView));
  }
  return footerViews;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:11,代码来源:ShadowListView.java

示例6: getRealAdapterCount

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
public static int getRealAdapterCount(ListAdapter adapter) {
    if (adapter == null) {
        return 0;
    }
    int count = adapter.getCount();
    if (adapter instanceof HeaderViewListAdapter) {
        HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter;
        count = count - headerViewListAdapter.getFootersCount() - headerViewListAdapter.getHeadersCount();
    }
    return count;
}
 
开发者ID:IstiN,项目名称:android_training_2014,代码行数:12,代码来源:MainActivity.java

示例7: setTitlesAndDrawerAndPage

import android.widget.HeaderViewListAdapter; //导入方法依赖的package包/类
static
void setTitlesAndDrawerAndPage(Fragment fragment, int absolutePos)
{
    String[] navTitles = s_resources.getStringArray(R.array.navigation_titles);

    if(null != fragment)
    {
        switchToFragment(fragment, false);
    }

    ListView list = s_fragmentDrawer.m_listView;
    HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) list.getAdapter();
    int headers = headerAdapter.getHeadersCount();

    int listPosition = -10 == absolutePos ? s_viewPager.getCurrentItem() + headers : absolutePos;
    int viewPagerPos = -10 == absolutePos ? s_viewPager.getCurrentItem() : absolutePos - headers;

    // Check the drawer item.
    String title = PagerAdapterTags.s_tagList.get(0);
    String subTitle = null;
    int imageRes = R.drawable.ic_action_labels;

    if(s_fragmentFavourites.isVisible())
    {
        listPosition = 0;
        title = navTitles[0];
        imageRes = R.drawable.ic_action_important;
    }
    else if(s_fragmentManage.isVisible())
    {
        listPosition = 1;
        title = navTitles[1];
        imageRes = R.drawable.ic_action_storage;
    }
    else if(s_fragmentSettings.isVisible())
    {
        listPosition = 2;
        title = navTitles[2];
        imageRes = R.drawable.ic_action_settings;
    }
    else
    {
        ArrayAdapter<String[]> adapter = (ArrayAdapter<String[]>) headerAdapter.getWrappedAdapter();

        if(null != adapter && 0 < adapter.getCount())
        {
            String[] item = adapter.getItem(viewPagerPos);
            title = item[0];
            int count = null == item[1] || item[1].isEmpty() ? 0 : Integer.parseInt(item[1]);
            String countString = s_resources.getQuantityString(R.plurals.actionbar_subtitle_unread, count, count);
            subTitle = 0 == count ? null : countString;
        }
    }
    s_actionBar.setTitle(title);
    s_actionBar.setSubtitle(subTitle);
    s_actionBar.setIcon(imageRes);

    list.setItemChecked(listPosition, true);

    // If we must change the view pager page.
    if(0 <= viewPagerPos)
    {
        // Switch the view pager page if different.
        if(s_viewPager.getCurrentItem() != viewPagerPos)
        {
            s_viewPager.setCurrentItem(viewPagerPos);
        }
    }
}
 
开发者ID:DarkangelKid,项目名称:rss,代码行数:70,代码来源:Utilities.java


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