Best code examples for Android ArrayAdapter class (android.widget.ArrayAdapter)

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

Android ArrayAdapter examples from Open Source projects
Examples using Android ArrayAdapter getCount method:
This code example shows how to use the following methods: getCount, getItem, isEmpty
13:	ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.id.text1); 
-
19:	assertFalse(adapter.isEmpty()); 
20:	assertEquals(3, adapter.getCount()); 
21:	assertEquals("test1", adapter.getItem(0)); 
22:	assertEquals("test2", adapter.getItem(1)); 
23:	assertEquals("test3", adapter.getItem(2)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getCount
81:	if (adapter.getCount() > 0) showDropDown(); 
Full Snippet Info
6
CodeRank
Examples using Android ArrayAdapter getItem method:
This code example shows how to use the following methods: getItem, insert, remove
41:	String oldTitle = this.headers.getItem(section); 
-
44:	this.headers.remove(oldTitle); 
45:	this.headers.insert(title, section); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getItem
48:	listener.onFeedSelected(adapter.getItem(position)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getItem
44:	mgr.registerListener(this, adapter.getItem(position), 
Full Snippet Info
6
CodeRank
Examples using Android ArrayAdapter add method:
This code example shows how to use the following methods: add
26:	ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), 
-
28:	adapter.add("ListView 1 Item 1"); 
29:	adapter.add("ListView 1 Item 2"); 
30:	adapter.add("ListView 1 Item 3"); 
31:	adapter.add("ListView 1 Item 4"); 
32:	adapter.add("ListView 1 Item 5"); 
33:	adapter.add("ListView 1 Item 6"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: add
25:	ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), 
-
27:	adapter.add("ListView 2 Item 1"); 
28:	adapter.add("ListView 2 Item 2"); 
29:	adapter.add("ListView 2 Item 3"); 
30:	adapter.add("ListView 2 Item 4"); 
31:	adapter.add("ListView 2 Item 5"); 
32:	adapter.add("ListView 2 Item 6"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: add, getCount
86:	if (BluetoothListDevicesActivity.this.mNewDevicesArrayAdapter.getCount() == 0) { 
87:	BluetoothListDevicesActivity.this.mNewDevicesArrayAdapter.add("No devices found!"); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDropDownViewResource
360:	ArrayAdapter<String> adapter = new ArrayAdapter<String>(cxt, 
-
362:	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDropDownViewResource
53:	android.R.layout.simple_spinner_item, mGroupList); 
54:	mGroupAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDropDownViewResource
51:	new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, 
-
54:	.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
Full Snippet Info
6
CodeRank
Examples using Android ArrayAdapter addAll method:
This code example shows how to use the following methods: addAll, clear
76:	listAdapter.clear(); 
77:	listAdapter.addAll(result); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addAll, clear
76:	listAdapter.clear(); 
77:	listAdapter.addAll(result); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: addAll, setDropDownViewResource
101:	ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item); 
102:	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
103:	adapter.addAll(field.getOptions()); 
Full Snippet Info
7
CodeRank
Examples using Android ArrayAdapter sort method:
This code example shows how to use the following methods: add, sort
156:	this.headers.add(section); 
-
168:	headers.sort(comp); 
Full Snippet Info
6
CodeRank
Examples for other Android ArrayAdapter methods:
Related Android ArrayAdapter Questions & Answers:
Other Android ArrayAdapter Examples
19:	        
20:	        // Binding resources Array to ListAdapter
21:	        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));
22:	        
23:	    }

Read More

17:		
18:		// Listview Adapter
19:		ArrayAdapter<String> adapter;
20:		
21:		// Search EditText
-
40:	        
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:

Read More

19:	        
20:	        // Binding resources Array to ListAdapter
21:	        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));
22:	        
23:	        ListView lv = getListView();

Read More

ArrayAdapter Class Overview
A concrete BaseAdapter that is backed by an array of arbitrary objects. By default this class expects that the provided resource id references a single TextView. If you want to use a more complex layout, use the constructors that also takes a field id. That field id should reference a TextView in the larger layout resource.

However the TextView is referenced, it will be filled with the toString() of each object in the array. You can add lists or arrays of custom objects. Override the toString() method of your objects to determine what text will be displayed for the item in the list. To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString() results fill the views, override getView...
Methods
  • add
    Adds the specified object at the end of the array.
  • addAll
    Adds the specified Collection at the end of the array.
  • clear
    Remove all elements from the list.
  • getFilter
    Returns a filter that can be used to constrain data with a filtering pattern.
  • insert
    Inserts the specified object at the specified index in the array.
  • notifyDataSetChanged
    Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.
  • remove
    Removes the specified object from the array.
  • sort
    Sorts the content of this adapter using the specified comparator.