如何在GridLayout中交换btn3和btn的位置?
final Button btn = new Button(this);
final Button btn2 = new Button(this);
final Button btn3 = new Button(this);
btn.setText("2");
btn2.setText("4");
btn3.setText("2");
final GridLayout gl = (GridLayout) this.findViewById(R.id.gridLayout);
gl.addView(btn);
gl.addView(btn2);
gl.addView(btn3);
答案 0 :(得分:0)
只需交换添加按钮的顺序。
gl.addView(btn3);
gl.addView(btn2);
gl.addView(btn);