Exercise: Making a user interface programmatically

Normally the user interface is declared in an XML file. However, the user interface can be made pragmatically in the Java Activity file - like we program a Java Swing interface.

In this exercise you will make a user interface programmatically.

The following sources tells you how to make user interfaces programmatically

The class ViewGroup (super-class of the various layout classes like LinearLayout, etc.) has methods like addView(...)

What you have to do

I want two activities similar to

If you type '3' and press the 'Create!' button you get 3 buttons.

Clicking any of these buttons should show a Toast like "You clicked button X" (where X is the number on the button), and then return to the main activity (use the finish()) method.