Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One solution is to create your own adapter since ArrayAdapter only uses one array, and not two. </p> <p>You can create the adapter as a private class within you ListActivity. Try something like this (warning: code not tested):</p> <pre><code>public class MyListActivity extends ListActivity { protected void onCreate(){ .... // Get arrays from resources Resources r = getResources(); String [] arr1 = r.getStringArray("menuEntryTitles"); String [] arr1 = r.getStringArray("menuEntryCaptions"); // Create your adapter MyAdapter adapter = new MyAdapter(arr1, arr2); setListAdapter(adapter); } private class MyAdapter extends BaseAdapter { private LayoutInflater inflater; String [] arr1; String [] arr2; public MyAdapter(String[] arr1, String[] arr2){ inflater = (LayoutInflater)MyListActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.arr1 = arr1; this.arr2 = arr2; } @Override public int getCount() { return arr1.length; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } // Used to keep references to your views, optimizes scrolling in list private static class ViewHolder { TextView tv1; TextView tv2; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null){ convertView = inflater.inflate(R.layout.row_layout, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder = new ViewHolder(); holder.tv1 = (TextView) convertView.findViewById(R.id.rowTitle); holder.tv2 = (TextView) convertView.findViewById(R.id.rowCaption); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } holder.tv1.setText(arr1[position]); holder.tv2.setText(arr2[position]); return convertView; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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