Create this layout xml (arrange the way you want) say item_layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView2" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New CheckBox"
android:id="@+id/checkBox" />
</LinearLayout>
Adding views
LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout scrollViewLinearlayout = (LinearLayout)findViewById(R.id.scroll_view_linear_layout); // The layout inside scroll view
for(int i = 0; i < count; i++){
LinearLayout layout2 = new LinearLayout(context);
layout2.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
View item = inflater.inflate(R.layout.item_layout, null, false);
layout2.setId(i);
layout2.addView(item);
scrollViewLinearlayout.addView(layout2);
}
Getting values from the view
for(int i = 0; i < count; i++){
LinearLayout itemLl = (LinearLayout)scrollViewLinearlayout.findViewById(i);
EditText et1 = (EditText)itemLl.findViewById(R.id.editText);
String et1Str = et1.getText().toString();
// Similarly get other values and add them in the database
}