JonathanPark JonathanPark - 5 months ago 12
Android Question

Creating textfields after hitting a button (Eclipse/Android)

I am trying to learn android development in Eclipse and I am stuck. I created a button with using this.

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="bla"
android:layout_gravity="center"
android:textSize="15dp"
android:id="@+id/bla"
/>


And my listener is the following.

button1=(Button) findViewById(R.id.bla);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

}
});


What I want is the following. When I click my button I want 3 different textfields to be seen. After I enter some values to that textfields, I want to get back to the initial screen which contains button1. How can I do that? Also with which method I can store the values that are written to this textfields?

Edit:All answers were helpful and I upvoted them but I accepted Diego's answer because of the clarity

Answer

If you want the EditText appear after you click a Button you can include all of them in the same XML layout file, set the EditText to INVISIBLE (android:visibility="invisible") and change it to VISIBLE in the OnClick listener.