當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。