Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot use SimpleAdapter on a ListFragment
    text
    copied!<p>I'm developing a ListView in an Android Fragment. The class extends ListFragment.</p> <p>I tried with this example: <a href="http://www.heikkitoivonen.net/blog/2009/02/15/multicolumn-listview-in-android/" rel="nofollow">http://www.heikkitoivonen.net/blog/2009/02/15/multicolumn-listview-in-android/</a></p> <p>but the problem is that constructor SimpleAdapter is not defined if the class extends ListFragment, changing it to ListActivity would make SimpleAdapter work, but then application won't.</p> <p>Here's the code:</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View tmp_view = inflater.inflate(R.layout.clients_list, container, false); ListView list = (ListView) tmp_view.findViewById(R.id.list); ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put("train", "101"); map.put("from", "6:30 AM"); map.put("to", "7:40 AM"); mylist.add(map); map = new HashMap&lt;String, String&gt;(); map.put("train", "103(x)"); map.put("from", "6:35 AM"); map.put("to", "7:45 AM"); mylist.add(map); // ... SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.clients_list_item, new String[] {"train", "from", "to"}, new int[] {R.id.TRAIN_CELL, R.id.FROM_CELL, R.id.TO_CELL}); list.setAdapter(mSchedule); ListFragment.setListAdapter(mSchedule); return tmp_view; } </code></pre> <p>So I will have no problem if this was an Activity, but it's a Fragment :S Any solution?</p>
 

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