我在运行时创建了 10 个按钮。我怎样才能得到他们的ID?
private void buttons() {
int count = 10;
for (int i = 0; i < count; i++) {
Button newButton = new Button(this);
newButton.setId("button_" + i);
LinearLayout ll = (LinearLayout)findViewById(R.id.linear);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
ll.addView(newButton,lp);
}
}
我需要做的是...
button_1.getX();