ListView getAdapter - 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 getAdapter method.

This code example shows how to use the following methods: getChildAt, performItemClick, getAdapter
	} 
 
	@Test 
	public void is_item_click_available_from_list_fragment() { 
		ListView listView = (ListView) myListFragment.findViewById(android.R.id.list);
		long itemId = listView.getAdapter().getItemId(TESTED_CLICKED_INDEX);
		View view = listView.getChildAt(TESTED_CLICKED_INDEX);
 
		assertThat(myListFragment.listItemClicked).isFalse();
		listView.performItemClick(view, TESTED_CLICKED_INDEX, itemId);
		assertThat(myListFragment.listItemClicked).isTrue();
	} 
 
	public static void startFragment(Fragment fragment) {
		FragmentManager fragmentManager = new FragmentActivity().getSupportFragmentManager();
		FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
		fragmentTransaction.add(fragment, null);
		fragmentTransaction.commit();
	} 
} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: setOnTouchListener, setOnScrollListener, getAdapter, setAdapter
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getChildAt, getChildCount, getListPaddingTop, getAdapter
                newLastChild.getId());
    } 
     
    @LargeTest 
    public void testShortScroll() { 
        View firstChild = mListView.getChildAt(0);
        if (firstChild.getTop() < this.mListView.getListPaddingTop()) {
            firstChild = mListView.getChildAt(1);
        } 
             
        View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
         
        int lastTop = lastChild.getTop();
         
        TouchUtils.dragViewBy(this, firstChild, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,
                0, ViewConfiguration.getTouchSlop() + 1 + 10);
         
        View newLastChild = mListView.getChildAt(mListView.getChildCount() - 1);
         
        assertEquals("View scrolled to wrong position", lastTop, newLastChild.getTop() - 10);

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: scrollToBottom, getHeight, getChildAt, getChildCount, getListPaddingBottom
                firstChild.getTop());
    } 
     
    @LargeTest 
    public void testPushUp() { 
        int originalCount = mListView.getChildCount();
         
        TouchUtils.scrollToBottom(this, mListView);
 
        // Nothing should be selected 
        assertEquals("Selection still available after touch", -1, 
                mListView.getSelectedItemPosition());
 
        View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
 
        assertEquals("List is not scrolled to the bottom", mListView.getAdapter().getCount() - 1,
                lastChild.getId());
 
        assertEquals("Last item is not touching the bottom edge",  
                mListView.getHeight() - mListView.getListPaddingBottom(), lastChild.getBottom());

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getDividerHeight
		int pBottom = (int) (getHeight() * paddingBottom / 100);
		v.setPadding(pLeft, pTop, pRight, pBottom);
	} 
 
	public static void makeListViewFullSize(ListView lv, int itemHeight) {
		int itemCount = lv.getAdapter().getCount();
		int divider = lv.getDividerHeight();
		int height = (itemHeight + divider) * itemCount;
		ViewGroup.LayoutParams lp = lv.getLayoutParams();
		lp.height = height;
		lv.setLayoutParams(lp);
	} 
 
} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getVerticalFadingEdgeLength, getChildCount, getSelectedView, getAdapter
 
    @MediumTest 
    public void testPreconditions() { 
        assertNotNull(mListView);
        assertTrue("need item height less than fading edge length",
                mListView.getSelectedView().getHeight() < mListView.getVerticalFadingEdgeLength());
        assertTrue("need items off screen",
                mListView.getChildCount() < mListView.getAdapter().getCount());
    } 
 
    @LargeTest 
    public void testScrollToBottom() { 
        final int numItems = mListView.getAdapter().getCount();
        final int listBottom = mListView.getHeight() - mListView.getListPaddingBottom();
        for (int i = 0; i < numItems; i++) {
            assertEquals("wrong selection at position " + i,
                    i, mListView.getSelectedItemPosition());
            final int bottomFadingEdge = listBottom - mListView.getVerticalFadingEdgeLength();
            final View lastChild = mListView.getChildAt(mListView.getChildCount() - 1);
            final int lastVisiblePosition = lastChild.getId();
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getAdapter
  public void testSpinnerCount() { 
    assertTrue(spinner.getAdapter().getCount()==3);
  } 
   
  public void testListDefaultCount() { 
    assertTrue(list.getAdapter().getCount()>0);
  } 
} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getDividerHeight
		int pBottom = (int) (getHeight() * paddingBottom / 100);
		v.setPadding(pLeft, pTop, pRight, pBottom);
	} 
 
	public static void makeListViewFullSize(ListView lv, int itemHeight) {
		int itemCount = lv.getAdapter().getCount();
		int divider = lv.getDividerHeight();
		int height = (itemHeight + divider) * itemCount;
		ViewGroup.LayoutParams lp = lv.getLayoutParams();
		lp.height = height;
		lv.setLayoutParams(lp);
	} 
 
	public static void makeGridViewFullSize(GridView gv, int itemHeight) {
		int itemCount = gv.getAdapter().getCount();
		int columns = gv.getNumColumns();
		int lines = (int) (itemCount / columns);
		if (itemCount % columns != 0) {
			lines++;
		} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getAdapter
    } 
  } 
   
  public void onListItemClick(ListView parent, View v, int position,
                  long id) {
    selection.setText(parent.getAdapter().getItem(position).toString());
  } 
     
  @Override 
  public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(Menu.NONE, LOCAL_SEARCH_ID, Menu.NONE, "Local Search")
            .setIcon(android.R.drawable.ic_search_category_default);
    menu.add(Menu.NONE, GLOBAL_SEARCH_ID, Menu.NONE, "Global Search")
            .setIcon(R.drawable.search)
            .setAlphabeticShortcut(SearchManager.MENU_KEY);
   
    return(super.onCreateOptionsMenu(menu));
  } 
 
  @Override 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getDividerHeight
		int pBottom = (int) (getHeight() * paddingBottom / 100);
		v.setPadding(pLeft, pTop, pRight, pBottom);
	} 
 
	public static void makeListViewFullSize(ListView lv, int itemHeight) {
		int itemCount = lv.getAdapter().getCount();
		int divider = lv.getDividerHeight();
		int height = (itemHeight + divider) * itemCount;
		ViewGroup.LayoutParams lp = lv.getLayoutParams();
		lp.height = height;
		lv.setLayoutParams(lp);
	} 
 
	public static void makeGridViewFullSize(GridView gv, int itemHeight) {
		int itemCount = gv.getAdapter().getCount();
		int columns = gv.getNumColumns();
		int lines = (int) (itemCount / columns);
		if (itemCount % columns != 0) {
			lines++;
		} 
Full Snippet Info
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related ListView getAdapter Questions & Answers:

getAdapter Method Overview
Returns the adapter currently in use in this ListView.
See Code Examples for other Android ListView Methods: