I have a button within a relative layout, and want it to create a new EditText in a different relative layout when pressed (a completely new EditText, not just turning the visibility on/off). This answer has helped, however I cannot change it to make it add an EditText instead of adding a new TextView. I don't need it to save the text inside any views or anything, just create another EditText, similar to an add contact button.
private EditText createNewEditText() {
final LayoutParams lparams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
final EditText edittext = new EditText(this);
Editext.setLayoutParams(lparams);
return edittext;
}
just make new relative in xml file
add this edittext like this
rl.addView(createNewEditText());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.