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
This code example shows how to use the following methods: getCount, getItem, isEmpty
 
import jp.mixi.compatibility.android.widget.ArrayAdapterCompat; 
 
public class ArrayAdapterCompatTest extends AndroidTestCase {
    public void testAddAllCollection() { 
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.id.text1);
        List<String> list = new ArrayList<String>();
        list.add("test1");
        list.add("test2");
        list.add("test3");
        ArrayAdapterCompat.addAll(adapter, list);
        assertFalse(adapter.isEmpty());
        assertEquals(3, adapter.getCount());
        assertEquals("test1", adapter.getItem(0));
        assertEquals("test2", adapter.getItem(1));
        assertEquals("test3", adapter.getItem(2));
    } 
 
    public void testAddAllArray() { 
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.id.text1);
        String[] array = new String[] {"test1", "test2", "test3"};
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getItem, insert, remove
        this.headers.add(section);  
        this.sections.put(section, adapter);  
    }   
 
    public void setSectionTitle(int section, String title) {
    	String oldTitle = this.headers.getItem(section);
 
    	// remove/add to headers array 
    	this.headers.remove(oldTitle);
    	this.headers.insert(title, section);
    	 
    	// remove/add to section map 
    	Adapter adapter = this.sections.get(oldTitle);
    	this.sections.remove(oldTitle);
    	this.sections.put(title, adapter);
    } 
     
    public Object getItem(int position) {  
        for(int i = 0; i < headers.getCount(); i++) {
        	String section = headers.getItem(i);
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
      public void onClick(View v) {
        List<String> list=Arrays.asList(items);
         
        Collections.shuffle(list);
         
        setListAdapter(new ArrayAdapter<String>(HeaderFooterDemo.this,
                            android.R.layout.simple_list_item_1,
                            list));
      } 
    }); 
     
    return(btn);
  } 
   
  private View buildFooter() {
    TextView txt=new TextView(this);
     
    updateFooter(txt);
     
    return(txt);
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: add
 
	private void init() { 
		setBackgroundColor(Color.GREEN);
		 
		ListView listView = new ListView(getContext());
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
				android.R.layout.simple_list_item_1);
		adapter.add("ListView 1 Item 1");
		adapter.add("ListView 1 Item 2");
		adapter.add("ListView 1 Item 3");
		adapter.add("ListView 1 Item 4");
		adapter.add("ListView 1 Item 5");
		adapter.add("ListView 1 Item 6");
 
		listView.setAdapter(adapter);
		 
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		addView(listView, params);
	} 
 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: add
	} 
 
	private void init() { 
		setBackgroundColor(Color.CYAN);
		ListView listView = new ListView(getContext());
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
				android.R.layout.simple_list_item_1);
		adapter.add("ListView 2 Item 1");
		adapter.add("ListView 2 Item 2");
		adapter.add("ListView 2 Item 3");
		adapter.add("ListView 2 Item 4");
		adapter.add("ListView 2 Item 5");
		adapter.add("ListView 2 Item 6");
 
		listView.setAdapter(adapter);
		 
		LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		addView(listView, params);
	} 
 
Full Snippet Info
7
CodeRank
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

See Code Examples for Android ArrayAdapter Methods: