Best code examples for ListView setAdapter method (android.widget.ListView.setAdapter)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListView setAdapter method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

ListView setAdapter examples from Open Source projects
This code example shows how to use the following methods: addHeaderView, setAdapter, setEmptyView, setFocusable, setOnItemClickListener
		super.onCreate(savedInstanceState);
 
		if (listViewId != 0) {
			listView = findListViewById(listViewId);
			if (headerView() != null) { 
				listView.addHeaderView(headerView());
			} 
			listView.setOnItemClickListener(this);
			android.view.View emptyView = findViewById(android.R.id.empty);
			if (emptyView != null) {
				listView.setEmptyView(emptyView);
			} 
 
			adapter = Objects.createInstance(adapterClass, Context.class, this);
			listView.setAdapter(adapter);
			listView.setFocusable(true);
		} 
	} 
 
	/** 
	 * Called after ListAdapter has been loaded 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: addFooterView, getFooterViewsCount, setAdapter, setSelection
        mDataIterator = pullRequestService.pagePullRequests(new RepositoryId(mRepoOwner, mRepoName), mState);
    } 
     
    private void fillData(List<PullRequest> pullRequests) {
        if (pullRequests != null && !pullRequests.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), pullRequests);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(pullRequests);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

9
CodeRank
This code example shows how to use the following methods: setOnTouchListener, setOnScrollListener, getAdapter, setAdapter
8
CodeRank
This code example shows how to use the following methods: getParent, setAdapter
        setupList(R.id.list1); 
    } 
 
    private void setupList(int listId) {
        final ListView list = (ListView) findViewById(listId);
        list.setAdapter(new SimpleListAdapter(this));
        list.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        ((View) list.getParent()).setLayerType(View.LAYER_TYPE_HARDWARE, null);
    } 
 
    private static class SimpleListAdapter extends ArrayAdapter<String> {
        public SimpleListAdapter(Context context) {
            super(context, android.R.layout.simple_list_item_1, DATA_LIST);
        } 
 
        @Override 
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView v = (TextView) super.getView(position, convertView, parent);
            final Resources r = getContext().getResources();
            final DisplayMetrics metrics = r.getDisplayMetrics();
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addFooterView, getFooterViewsCount, setAdapter, setSelection
        } 
    } 
     
    private void fillData(List<Repository> repositories) {
        if (repositories != null && !repositories.isEmpty()) {
            if (mListView.getFooterViewsCount() == 0) {
                mListView.addFooterView(mLoadingView);
                mListView.setAdapter(mAdapter);
            } 
            if (isLoadMore) {
                mAdapter.addAll(mAdapter.getCount(), repositories);
                mAdapter.notifyDataSetChanged();
            } 
            else { 
                mAdapter.clear();
                mAdapter.addAll(repositories);
                mAdapter.notifyDataSetChanged();
                mListView.setSelection(0);
            } 
        } 

8
CodeRank
Related ListView setAdapter Questions & Answers:
Other ListView setAdapter Examples
80:			adapter = new NavDrawerListAdapter(getApplicationContext(),
81:					navDrawerItems);
82:			mDrawerList.setAdapter(adapter);
83:	
84:			// enabling action bar app icon and behaving it as toggle button

Read More

56:			adapter = new NavDrawerListAdapter(getApplicationContext(),
57:					navDrawerItems);
58:			mDrawerList.setAdapter(adapter);
59:	
60:			// enabling action bar app icon and behaving it as toggle button

Read More

41:	        // Adding items to listview
42:	        adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.product_name, products);
43:	        lv.setAdapter(adapter);
44:	        
45:	        /**

Read More

setAdapter Method Overview
Sets the data behind this ListView.
See Code Examples for other Android ListView Methods: