获得指定activity中的VIEW,通过代码的形式
public class GetActivityView {
private Activity context;
private View view;
public GetActivityView(Activity context){
this.context = context;
}
public List<View> getAllChildViews() {
View view = context.getWindow().getDecorView();
return getAllChildViews(view);
}
public List<View> getAllChildViews(View view) {
List<View> allchildren = new ArrayList<View>();
if (view instanceof ViewGroup) {
ViewGroup vp = (ViewGroup) view;
for (int i = 0; i < vp.getChildCount(); i++) {
View viewchild = vp.getChildAt(i);
String name = viewchild.getClass().getSimpleName();
System.out.println(name);
allchildren.add(viewchild);
allchildren.addAll(getAllChildViews(viewchild));
}
}
return allchildren;
}
public List<View> getAllChildViewsByName(View view,String name) {
List<View> allchildren