Android - ListView only show the first result

Rorchackh picture Rorchackh · Mar 23, 2012 · Viewed 33.4k times · Source

I am working on an android app which interacts with Twitter using their search API. Everythings works well except that when I want to show the result using a ListView, only the first result is shown.

ArrayList<TwitterJSONResults> arrayList = new ArrayList<TwitterJSONResults>(data.getResults().size());
for (int i = 0; i < data.getResults().size(); i++) {
    arrayList.add(data.getResults().get(i));
}

ArrayAdapter<TwitterJSONResults> resultAdapter = new ArrayAdapter<TwitterJSONResults>(
                this, android.R.layout.simple_list_item_1, arrayList);
listview.setAdapter(resultAdapter);
resultAdapter.notifyDataSetChanged();

The code snippet above show how I add the results to the adapter and set this adapter to the the listview, What am I doing wrong?

Answer

207 picture 207 · Mar 23, 2012

Don't put ListView inside of a ScrollView :)