Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can Customizing Android ListView Items with Custom ArrayAdapter.</p> <p>You can do this way,</p> <pre><code>/* In main activity */ ListView myListView = (ListView)findViewById(R.id.myListView); final ArrayList&lt;Phonebook&gt; todoItems = new ArrayList&lt;Phonebook&gt;(); final YourAdapter x= new YourAdapter(this,R.layout.your_listviewlayout,todoItems); myListView.setAdapter(x); Phonebook phnbk= new Phonebook(); // enter code for set values to Phonebook class variables /* Inserting the values to array */ todoItems.add(phnbk); /* Customized array adaptor class */ private class YourAdapter extends ArrayAdapter&lt;Phonebook&gt; { private ArrayList&lt;Phonebook&gt; items; public YourAdapter (Context context, int textViewResourceId, ArrayList&lt;Phonebook&gt; items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.your_listviewlayout, null); } Phonebook o = items.get(position); if (o != null) { //insert values to each text view in your list view layout tv1.setText(o.name); tv2.setText(o.phnnum); tv3.setText(o.email); } return v; } } /* Phonebook class */ public class Phonebook{ public String name; public String phnnum; public String email; public Phonebook(){ super(); } public Phonebook(String name, String phnnum, String email) { super(); this.name = name; this.phnnum = phnnum; this.email = email; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload