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

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 
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();
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
This code example shows how to use the following methods:setAdapter
		adapter = new ActivitiesAdapter(context, activities, user);
		displayActivities(); 
	} 
	 
	private void displayActivities() { 
		activityList.setAdapter(adapter);
	} 
 
} 
8
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
This code example shows how to use the following methods:setAdapter
		super.onCreate(savedInstanceState);
 
		db = new MyDatabase(this);
		employees = db.getEmployees(); // you would not typically call this on the main thread
 
		ListAdapter adapter = new SimpleCursorAdapter(this, 
				android.R.layout.simple_list_item_1, 
				employees, 
				new String[] {"FirstName"}, 
				new int[] {android.R.id.text1});
 
		getListView().setAdapter(adapter);
	} 
 
	@Override 
	protected void onDestroy() { 
		super.onDestroy(); 
		employees.close();
		db.close();
	} 
8
CodeRank
This code example shows how to use the following methods:setAdapter, setEmptyView, setFocusable, setOnItemClickListener
        super.onCreate(savedInstanceState);
 
        if (listViewId != 0) {
            listView = findListViewById(listViewId);
 
            listView.setOnItemClickListener(this);
            android.view.View emptyView = findViewById(android.R.id.empty);
            if (emptyView != null) {
                log("emptyview is set"); 
                listView.setEmptyView(emptyView);
            } else { 
                log("emptyview is not empty"); 
            } 
 
            adapter = Objects.createInstance(adapterClass, Context.class, this);
            listView.setAdapter(adapter);
            listView.setFocusable(true);
        } 
        EasyTracker.getInstance().setContext(this);
    } 

7
CodeRank
This code example shows how to use the following methods:setAdapter, setOnItemClickListener
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(getIntent().hasExtra(ACTION_ADW_PICK_RESOURCE)){
        	mResourceMode=true;
        } 
        ListView lv=new ListView(this);
        lv.setAdapter(new DocksAdapter(this));
        lv.setOnItemClickListener(this);
        setContentView(lv);
        CONTENT_URI=Uri.parse("content://"+DocksProvider.class.getCanonicalName());
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    	Intent result;
    	int resourceId=(Integer)adapterView.getItemAtPosition(i);
    	if(!mResourceMode){
            String dock=String.valueOf(resourceId);
            result = new Intent(null, Uri.withAppendedPath(CONTENT_URI,dock));
    	}else{ 
7
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: