ListView getHeaderViewsCount - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListView getHeaderViewsCount method.

This code example shows how to use the following methods:getContext, getChildAt, getHeaderViewsCount, getFirstVisiblePosition
     * This simple implementation creates a Bitmap copy of the list item 
     * currently shown at ListView <code>position</code>. 
     */ 
    @Override 
    public View onCreateFloatView(int position) {
        View v = mListView.getChildAt(position + mListView.getHeaderViewsCount()
                - mListView.getFirstVisiblePosition());
 
        if (v == null) {
            return null; 
        } 
 
        v.setPressed(false);
 
        v.setDrawingCacheEnabled(true);
        mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
        v.setDrawingCacheEnabled(false);
 
        ImageView iv = new ImageView(mListView.getContext());
        iv.setBackgroundColor(mFloatBGColor);

8
CodeRank
This code example shows how to use the following methods:isInTouchMode, getChildAt, getHeaderViewsCount, getItemsCanFocus
        mListView = getActivity().getListView();
    } 
 
    @MediumTest 
    public void testPreconditions() { 
        assertTrue("listview.getItemsCanFocus()", mListView.getItemsCanFocus());
        assertFalse("out of touch-mode", mListView.isInTouchMode());
        assertEquals("header view count", 1, mListView.getHeaderViewsCount());
        assertTrue("header has focus", mListView.getChildAt(0).isFocused());
    } 
 
    @FlakyTest(tolerance=2) 
    @LargeTest 
    public void testClickingHeaderKeepsFocus() { 
        TouchUtils.clickView(this, mListView.getChildAt(0));
        assertTrue("header has focus", mListView.getChildAt(0).isFocused());
        assertEquals("nothing selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
    } 
 
    @LargeTest 
7
CodeRank
This code example shows how to use the following methods:getChildAt, getHeaderViewsCount, getFirstVisiblePosition, getLastVisiblePosition
        ((TextView) textView).setTypeface(face);
    } 
 
    // ListView 
    public static View getChildAtPosition(ListView listView, int position) {
        int firstPostion = listView.getFirstVisiblePosition();
        int lastPostion = listView.getLastVisiblePosition();
 
        if ((position < firstPostion) || (position > lastPostion)) {
            return null; 
        } 
 
        return listView.getChildAt(position - firstPostion
                + listView.getHeaderViewsCount());
    } 
 
    @TargetApi(11) 
    public static void setLayerType(View view, int layerType, Paint paint) {
        if (BuildHelper.isApi11_HoneyCombOrLater()) { 
            view.setLayerType(layerType, paint);
6
CodeRank
This code example shows how to use the following methods:isInTouchMode, getChildAt, getHeaderViewsCount, getItemsCanFocus
        mListView = getActivity().getListView();
    } 
 
    @MediumTest 
    public void testPreconditions() { 
        assertTrue("listview.getItemsCanFocus()", mListView.getItemsCanFocus());
        assertFalse("out of touch-mode", mListView.isInTouchMode());
        assertEquals("header view count", 1, mListView.getHeaderViewsCount());
        assertTrue("header has focus", mListView.getChildAt(0).isFocused());
    } 
 
    @FlakyTest(tolerance=2) 
    @LargeTest 
    public void testClickingHeaderKeepsFocus() { 
        TouchUtils.clickView(this, mListView.getChildAt(0));
        assertTrue("header has focus", mListView.getChildAt(0).isFocused());
        assertEquals("nothing selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
    } 
 
    @LargeTest 
6
CodeRank
This code example shows how to use the following methods:getContext, getChildAt, getHeaderViewsCount, getFirstVisiblePosition
     */ 
    @Override 
    public View onCreateFloatView(int position) {
        // Guaranteed that this will not be null? I think so. Nope, got 
        // a NullPointerException once... 
        View v = mListView.getChildAt(position + mListView.getHeaderViewsCount() - mListView.getFirstVisiblePosition());
 
        if (v == null) {
            return null; 
        } 
 
        v.setPressed(false);
 
        // Create a copy of the drawing cache so that it does not get 
        // recycled by the framework when the list tries to clean up memory 
        //v.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); 
        v.setDrawingCacheEnabled(true);
        mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
        v.setDrawingCacheEnabled(false);
 

6
CodeRank
This code example shows how to use the following methods:getAdapter, getHeaderViewsCount
	 * @see android.app.ListFragment#onListItemClick(android.widget.ListView, android.view.View, int, long) 
	 */ 
	@Override 
	@SuppressWarnings("unchecked") 
	public void onListItemClick(ListView listView, View v, int position, long id) {
		int headersCount = listView.getHeaderViewsCount();
		int pos = position - headersCount;
		if ((pos >= 0) && (pos < listView.getAdapter().getCount())) {
			T t = (T)listView.getAdapter().getItem(pos);
			onItemSelected(t);
		} 
	} 
	 
	/** 
	 * @param item 
	 */ 
	@Override 
	public void onItemSelected(T item) {
		// Do Nothing 
	} 
5
CodeRank

Related ListView getHeaderViewsCount Questions & Answers:

getHeaderViewsCount Method Overview
Returns the number of header views in the list.
See Code Examples for other Android ListView Methods: