ArrayAdapter add - 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 add method.

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);
	} 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
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);
	} 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
      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) {
    this.listener=listener;
  } 
   
  public interface OnFeedListener { 
    void onFeedSelected(Feed feed);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add, getCount
					BluetoothListDevicesActivity.this.mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); 
				} 
			} else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) { 
				BluetoothListDevicesActivity.this.setProgressBarIndeterminateVisibility(false); 
				BluetoothListDevicesActivity.this.setTitle("Select a device to connect..."); 
				if (BluetoothListDevicesActivity.this.mNewDevicesArrayAdapter.getCount() == 0) { 
					BluetoothListDevicesActivity.this.mNewDevicesArrayAdapter.add("No devices found!"); 
				} 
			} 
		} 
	}; 
 
 
	// =========================================================== 
	// Constructors 
	// =========================================================== 
 
	@Override 
	protected void onCreate(final Bundle pSavedInstanceState) {
		super.onCreate(pSavedInstanceState);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
      } 
    } 
  } 
 
  public void addNewFeed(Feed feed) {
    adapter.add(feed);
  } 
 
  private class NavListener implements ActionBar.OnNavigationListener {
    public boolean onNavigationItemSelected(int itemPosition,
                                            long itemId) {
      FragmentManager fragMgr=getSupportFragmentManager();
      FragmentTransaction xaction=fragMgr.beginTransaction();
 
      addItems(xaction, Feed.getFeeds().get(itemPosition));
      removeFragments(fragMgr, xaction);
      xaction.commit();
 
      return(true); 
    } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
  } 
 
  @Override 
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
      adapter.add(v.getText().toString());
      v.setText("");
 
      InputMethodManager imm=
          (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
 
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    } 
 
    return(true); 
  } 
 
  private void configureActionItem(Menu menu) {
    EditText add=
        (EditText)menu.findItem(R.id.add).getActionView()
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add, sort
			throw new InvalidParameterException(ERRORMSG);
		} 
		if (adapter == null) {
			throw new NullPointerException();
		} 
		this.headers.add(section);
		SimpleCursorAdapter prev = this.sections.put(section, adapter);
		if (prev != null) {
			Log.d("listproto", "killing previous adapter");
			prev.unregisterDataSetObserver(subObserver);
			prev.swapCursor(null);
		} 
		if (adapter != null) {
			adapter.registerDataSetObserver(subObserver);
		} 
		// Need to sort the headers each time it changes 
		if (comp != null) {
			headers.sort(comp);
		} 
	} 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
    public SeparatedListAdapter(Context context) {  
        headers = new ArrayAdapter<String>(context, R.layout.list_header);  
    }   
   
    public void addSection(String section, Adapter adapter) {  
        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);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
        sendText(); 
    } 
 
    private void sendText() { 
        String text = mUserText.getText().toString();
        mAdapter.add(text);
        mUserText.setText(null);
    } 
 
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    sendText(); 
                    return true; 
            } 
        } 
        return false; 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
	public SeparatedListAdapter(Context context) {
		headers = new ArrayAdapter<String>(context, R.layout.list_header);
	} 
 
	public void addSection(String section, Adapter adapter) {
		this.headers.add(section);
		this.sections.put(section, adapter);
	} 
 
	public Object getItem(int position) {
		for (Object section : this.sections.keySet()) {
			Adapter adapter = sections.get(section);
			int size = adapter.getCount() + 1;
 
			// check if position inside this section 
			if (position == 0)
				return section;
			if (position < size)
				return adapter.getItem(position - 1);
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related ArrayAdapter add Questions & Answers:

add Method Overview
Adds the specified object at the end of the array.
See Code Examples for other Android ArrayAdapter Methods: