- private void getButtons(ViewGroup viewGroup) {
- if (viewGroup == null) {
- return;
- }
- int count = viewGroup.getChildCount();
- for (int i = 0; i < count; i++) {
- View view = viewGroup.getChildAt(i);
- if (view instanceof Button) { // 若是Button记录下
- Button newDtv = (Button) view;
- } else if (view instanceof ViewGroup) {
- // 若是布局控件(LinearLayout或RelativeLayout),继续查询子View
- this.getButtons((ViewGroup) view);
- }
- }
- }
-