ArrayAdapter getItem - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ArrayAdapter getItem method.

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"};
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);
8
CodeRank
This code example shows how to use the following methods:getItem
  public void onListItemClick(ListView l, View v, int position,
                              long id) {
    super.onListItemClick(l, v, position, id);
     
    if (listener!=null) {
      listener.onFeedSelected(adapter.getItem(position));
    } 
  } 
   
  public void addNewFeed(Feed feed) {
    adapter.add(feed);
  } 
 
  private void loadFeeds() { 
    adapter=new ArrayAdapter<Feed>(getActivity(), R.layout.row,
                                    Feed.getFeeds()); 
    setListAdapter(adapter);
  } 
   
  public void setOnFeedListener(OnFeedListener listener) {
7
CodeRank
This code example shows how to use the following methods:getItem
  } 
 
  @Override 
  public void onListItemClick(ListView l, View v, int position, long id) {
    mgr.unregisterListener(this);
    mgr.registerListener(this, adapter.getItem(position),
                         SensorManager.SENSOR_DELAY_NORMAL);
  } 
 
  @Override 
  public void onAccuracyChanged(Sensor sensor, int accuracy) {
    // TODO Auto-generated method stub 
  } 
 
  @Override 
  public void onSensorChanged(SensorEvent event) {
    mgr.unregisterListener(this);
 
    Toast.makeText(getActivity(),
                   String.format(getActivity().getString(R.string.toast_template),
6
CodeRank
This code example shows how to use the following methods:getItem
        setListAdapter(mAdapter);
    } 
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Tip tip = mAdapter.getItem(position);
        if (tip != null) {
            startActivity(tip.intent);
        } 
    } 
     
    /** 
     * Represents a single ListView tip & trick in the list of all tips. A 
     * {@link Tip} is basically a title and an Intent to the Activity demo-ing 
     * the tip & trick 
     *  
     * @author Cyril Mottier 
     */ 
    private static class Tip { 
        public String title;
6
CodeRank
This code example shows how to use the following methods:getItem
        mAdapter = adapter;
    } 
 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        TagDescription description = mAdapter.getItem(position);
        Intent intent = new Intent(NfcAdapter.ACTION_TAG_DISCOVERED);
        intent.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, description.msgs);
        startActivity(intent);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getItem
	@Override 
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long duration) {
		// Upon clicking item in list pop a toast 
		String msg = "#Item: " + String.valueOf(position) + " - "
				+ listAdapter.getItem(position);
		Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getItem, remove
        attributeAdpt.add(attr);
        attributeList.add(attr);
    } 
     
    private String removeAttribute(int pos) {
        String str = attributeAdpt.getItem(pos);
        if (str != null) {
            attributeAdpt.remove(str);
            attributeList.remove(str);
        } 
        return str;
    } 
     
    private void addEnteredAttribute() { 
        Editable e = entry.getText();
         
        String attrStr = e.toString();
     
        if (attrStr.length() == 0)
            return; 
5
CodeRank
This code example shows how to use the following methods:getItem
        mAdapter = adapter;
    } 
 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        final TagDescription description = mAdapter.getItem(position);
        final Intent intent = new Intent(NfcAdapter.ACTION_TAG_DISCOVERED);
        intent.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, description.msgs);
        startActivity(intent);
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getItem
        mAdapter = adapter;
    } 
 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        final TagDescription description = mAdapter.getItem(position);
        final Intent intent = new Intent(NfcAdapter.ACTION_TAG_DISCOVERED);
        intent.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES, description.msgs);
        startActivity(intent);
    } 
} 
5
CodeRank

Related ArrayAdapter getItem Questions & Answers:

getItem Method Overview
See Code Examples for other Android ArrayAdapter Methods: