
The logic's the same though.Ĭreate the initial list at the start of your class with the buttons: ArrayList buttons = new ArrayList() īuttons.add(new Button("button1", xPos, yPos)) īuttons.add(new Button("button2", xPos, yPos)) īuttons.add(new Button("button3", xPos, yPos)) īuttons.add(new Button("button4", xPos, yPos)) If not, it might be a bit more cumbersome. This is assuming you have some sort of class for your buttons. If you want to use the solution you describe in your question, you can achieve it pretty easily with an ArrayList.

I have each button in a separate frame layout which stay where they are with the buttons inside swapping which frame container they are inside. Now simply insert each button into the other buttons frame layout.

ViewManager p2 = (ViewManager) v2.getParent() Remove the other button from it's frame layout parent. List buttons = new void onCreate(Bundle savedInstanceState) while (v2 = v) // Loop until you get a different button to swap with. Each button have the same onClick method buttonClicked(). I created a working demo using android's built-in buttons.
