Android Adapter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Adapter class.

This code example shows how to use the following methods:getCount
    private final List<DataSetObserver> dataSetObservers = new ArrayList<DataSetObserver>();
    private boolean wasNotifyDataSetChangedCalled;
 
    @Implementation 
    public boolean isEmpty() { 
    	return realBaseAdapter.getCount() == 0;
    } 
 
    /** 
     * Just returns true 
     * 
     * @return true 
     */ 
    @Implementation 
    public boolean areAllItemsEnabled() { 
        return true; 
    } 
 
    /** 
     * Registers the observer. 
7
CodeRank
This code example shows how to use the following methods:registerDataSetObserver
                      ViewGroup parent) {
    return(delegate.getView(position, convertView, parent));
  } 
   
  public void registerDataSetObserver(DataSetObserver observer) {
    delegate.registerDataSetObserver(observer);
  } 
   
  public boolean hasStableIds() { 
    return(delegate.hasStableIds());
  } 
   
  public boolean isEmpty() { 
    return(delegate.isEmpty());
  } 
   
  public int getViewTypeCount() { 
    return(delegate.getViewTypeCount());
  } 
   
7
CodeRank
This code example shows how to use the following methods:getItem
    } 
 
    public Object getItemAtPosition(int position) {
        T adapter = getAdapter();
        return adapter == null || position < 0 ? null : adapter
                .getItem(position);
    } 
 
    public long getItemIdAtPosition(int position) {
        T adapter = getAdapter();
        return adapter == null || position < 0 ? AdapterView.INVALID_ROW_ID
                : adapter.getItemId(position);
    } 
 
    public int getLastVisiblePosition() { 
        return mFirstPosition + getChildCount() - 1;
    } 
 
    public final OnItemClickListener getOnItemClickListener() { 
        return mOnItemClickListener;
6
CodeRank
This code example shows how to use the following methods:getCount, getView
        int preferredHeight = 0;
        int preferredWidth = 0;
        boolean needsMeasuring = true;
 
        int selectedPosition = getSelectedItemPosition();
        if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) {
            // Try looking in the recycler. (Maybe we were measured once already) 
            View view = mRecycler.get(selectedPosition);
            if (view == null) {
                // Make a new one 
                view = mAdapter.getView(selectedPosition, null, this);
            } 
 
            if (view != null) {
                // Put in recycler for re-measuring and/or layout 
                mRecycler.put(selectedPosition, view);
            } 
 
            if (view != null) {
                if (view.getLayoutParams() == null) {
6
CodeRank
This code example shows how to use the following methods:registerDataSetObserver
        } else if (mAdapter != null) {
            mAdapter.unregisterDataSetObserver(mObserver);
        } 
        mAdapter = adapter;
        if (mAdapter != null) {
            adapter.registerDataSetObserver(mObserver);
        } 
 
        if (mDropDownList != null) {
            mDropDownList.setAdapter(mAdapter);
        } 
    } 
 
    public void setPromptPosition(int position) {
        mPromptPosition = position;
    } 
 
    public void setModal(boolean modal) {
        mModal = true;
        mPopup.setFocusable(modal);
7
CodeRank
This code example shows how to use the following methods:registerDataSetObserver
		return wrapped.isEnabled(i);
	} 
 
	@Override 
	public void registerDataSetObserver(DataSetObserver dataSetObserver) {
		wrapped.registerDataSetObserver(dataSetObserver);
	} 
 
	@Override 
	public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
		wrapped.unregisterDataSetObserver(dataSetObserver);
	} 
 
	@Override 
	public int getCount() { 
		return wrapped.getCount();
	} 
 
	@Override 
	public Object getItem(int i) {
6
CodeRank
This code example shows how to use the following methods:getCount, registerDataSetObserver
                // adapter.  It is now time to show it. 
                setListShown(true, getView().getWindowToken() != null); 
            } 
        } 
        updateEmpty(); 
        mAdapter.registerDataSetObserver(new DataSetObserver() {
            @Override 
            public void onChanged() { 
                super.onChanged(); 
 
                updateEmpty(); 
            } 
 
            @Override 
            public void onInvalidated() { 
                super.onInvalidated(); 
 
                updateEmpty(); 
            } 
 

5
CodeRank
This code example shows how to use the following methods:getCount
    public void testPreconditions() {	 
        assertNotNull(mStatusView);
        assertNotNull(mAccountsSpinner);
 
        assertTrue(mAccountAdapter != null);
        assertEquals(mAccountAdapter.getCount(),1);
    } 
     
    public void testStatusRegisteredText() { 
    	status = mActivity.getString(sg.macbuntu.android.pushcontacts.R.string.status_registered);
        assertEquals(status,(String)mStatusView.getText());
    } 
     
    public void testStatusNotRegisteredText() { 
    	status = mActivity.getString(sg.macbuntu.android.pushcontacts.R.string.status_not_registered);
        assertEquals(status,(String)mStatusView.getText());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:registerDataSetObserver
        } 
    }; 
 
    public StickyGridHeadersListAdapterWrapper(ListAdapter adapter) {
        mDelegate = adapter;
        adapter.registerDataSetObserver(mDataSetObserver);
    } 
 
    @Override 
    public int getCount() { 
        return mDelegate.getCount();
    } 
 
    @Override 
    public Object getItem(int position) {
        return mDelegate.getItem(position);
    } 
 
    @Override 
    public long getItemId(int position) {
6
CodeRank
This code example shows how to use the following methods:getCount
 
        /* 
         *  Also ensure that the backing mLocalAdapter has the correct number of entries. 
         */ 
 
        assertEquals(mPlanetData.getCount(), ADAPTER_COUNT);
    } 
 
    /* 
     * Tests the UI of the main activity. Sends key events (keystrokes) to the UI, then checks 
     * if the resulting spinner state is consistent with the attempted selection. 
     */ 
    public void testSpinnerUI() { 
 
        /* 
         * Request focus for the spinner widget in the application under test, 
         * and set its initial position. This code interacts with the app's View 
         *  so it has to run on the app's thread not the test's thread. 
         * 
         * To do this, pass the necessary code to the application with 
6
CodeRank

Related Android Adapter Questions & Answers:

See Code Examples for Android Adapter Methods: