public class LayoutParamsUtil {
public static LinearLayout.LayoutParams getLLParamWeightWCWC(float weight) {
return new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.WRAP_CONTENT, weight);
}
public static LinearLayout.LayoutParams getLLParamWeightMPWC(float weight) {
return new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.WRAP_CONTENT, weight);
}
public static void createEditTexts(Context context,
String[] titleInHeading,
String[] hintInValueField,
ScrollView scrollLinearLayout) {
if(titleInHeading!= null && hintInValueField != null && titleInHeading.length == hintInValueField.length) {
LinearLayout llRootLayout = new LinearLayout(context);
llRootLayout.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < titleInHeading.length; i++) {
LinearLayout ll2ViewBinder = new LinearLayout(context);
ll2ViewBinder.setOrientation(LinearLayout.HORIZONTAL);
ll2ViewBinder.setWeightSum(WEIGHT_SUM);
TextView tvHeading = new TextView(context);
tvHeading.setText(titleInHeading[i]);
tvHeading.setTextSize(20);
tvHeading.setTextColor(context.getResources().getColor(android.R.color.black));
tvHeading.setLayoutParams(LayoutParamsUtil.getLLParamWeightWCWC(WEIGHT_0POINT3));
EditText etValueField = new EditText(context);
etValueField.setHint(hintInValueField[i]);
etValueField.setTextSize(20);
etValueField.setTag(titleInHeading[i]); //used to get Value from EditText
etValueField.setLayoutParams(LayoutParamsUtil.getLLParamWeightMPWC(WEIGHT_0POINT7));
ll2ViewBinder.addView(tvHeading);
ll2ViewBinder.addView(etValueField);
llRootLayout.addView(ll2ViewBinder);
}
scrollLinearLayout.addView(llRootLayout);
}
}
}