LinearLayout linearLayout = (LinearLayout) findViewById(R.id.main_container);
OnClickListener listener = new NewClickListener();
Logger.Logger_d("linearLayout.getChildCount:"+linearLayout.getChildCount());
打印出所有子视图数量
for (int i = 0; i < linearLayout.getChildCount(); i++) {
View view = linearLayout.getChildAt(i);
if (view instanceof Button) {
view.setOnClickListener(listener);
}
}
得到子视图,查看视图继承关系进行下一步操作
时间: 2024-10-17 15:24:57