how to fill in scroll view from file or database or any data source?
I want to bind data from an xml file? how can I do that wher开发者_如何学Pythone i'm using a layout xml file to define a scrollview ??
If i've understood your question right, you want to read a layout file and insert it into a ScrollView.
You would want to take a look LayoutInflater for this task. Example for doing this from an activity.
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ScrollView sv = findViewById(R.id.id_of_scrollview);
inflater.inflate(R.layout.id_of_layoutfile_to_include, sv);
EDIT: After having read your comment i realise that i misunderstood your question.
ScrollView is not the view you want for binding your data, scrollView is a specialized frameLayout, and therefore only allows one child.
Your most likely looking for a view like ListView (Which adds scrolling automatically)
Another solution is to use a Layout in a scrollview and dynamically (From code) add the views.
LinearLayout ll = findViewById(R.id.id_of_linearlayout);
//Loop data and build a view for each data entry and add it with
ll.addView(yourView);
精彩评论