我想以编程方式在TextInputLayout中插入TextInputEditText,但是,我不能这样做,因为我现在不知道怎么做,只显示我的EditText。 OBS:该方法负责添加3次,一个EditText,但现在我想插入一个TextInputLayout而不是EditText
private void configLayout(View view, LinearLayout ll) {
String[] hint = new String[]{"Name", "E-mail", “Phone”};
for (int i = 0; i < 3; i++) {
LinearLayout temp = new LinearLayout(view.getContext());
temp.setOrientation(LinearLayout.VERTICAL);
temp.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
TextInputEditText et = new TextInputEditText(view.getContext());
et.setHint(hint[i]);
LinearLayout.LayoutParams llpNome = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
llpNome.setMargins(0, 16, 0, 0);
et.setLayoutParams(llpNome);
temp.addView(et);
TextInputLayout til = new TextInputLayout(view.getContext(), null, R.style.stl_til);
LinearLayout.LayoutParams llpTil = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
llpTil.setMargins(0, 16, 0, 0);
til.setLayoutParams(llpTil);
til.setHint(hint[i]);
temp.addView(til);
ll.addView(temp);
}
}