ListView showing only one results, do you use Scrollview ?


Please remember not to use ListView under ScrollView since both view have “scroll” features. When you put ListView under ScrollView, the ListView will only showing one results.

You can use dynamic adding view / programmatically into ScrollView to make “List” format.
Some example :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
String[] statusConsultation = {"First data", "Second data", "Third data"};

LinearLayout statusLayout = (LinearLayout) view
                .findViewById(R.id.statusConsultationLayout);
statusLayout.removeAllViews();

for (int i = 0; i < statusConsultation.length; i++) {
    View childView = inflater.inflate(
            R.layout.status_fragment_list_layout, null);

    TextView statusDetailView = (TextView) childView
                    .findViewById(R.id.statusListDetailTextview);
    statusDetailView.setText(Html.fromHtml(statusConsultation[i]));

    statusLayout.addView(childView);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.