I want to create an onclick event that creates an EditText. I have tried the following code but it erases everything and creates a new Layout with a EditText.
public class MainActivity extends Activity {
    ArrayList<Contact> contact;
    Contact currentcontact;
    EditText nameArea,emailArea,phoneArea;
    int emails=1;
    int phones=1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        nameArea=findViewById(R.id.name_area);
        emailArea=findViewById(R.id.e1);
        phoneArea=findViewById(R.id.p1);
        contact=new ArrayList<>();
    }
    public void buttonclick(View v){
        if(v.getId()==R.id.addemail){
            createemaileditview();
        }
        if(v.getId()==R.id.addphone){
            createphoneeditview();
        }
        if(v.getId()==R.id.save){
        }
        if(v.getId()==R.id.cancel){
        }
    }
    protected void createemaileditview(){
        LinearLayout outerLayout=new LinearLayout(this);
        outerLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT));
        outerLayout.setOrientation(LinearLayout.VERTICAL);
        EditText email=new EditText(this);
        email.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT,1f));
        outerLayout.addView(email);
        setContentView(outerLayout);
        emails++;
    }
    protected void createphoneeditview(){
        phones++;
    }
}
 
     
     
    