I would like to get a list of all views inside a main Fragment
, so that I could iterate through them in a for loop. Maybe something like this:
for (View v : fragmentViews) {
I would like to get a list of all views inside a main Fragment
, so that I could iterate through them in a for loop. Maybe something like this:
for (View v : fragmentViews) {
Inflate your fragment the usual way in your onCreateView
:-
View rootView = inflater.inflate(R.layout.my_fragment, container, false);
To loop through views of your fragment:
ViewGroup container = (ViewGroup) rootView;
int count = container.getChildCount();
for (int i = 0; i < count; i++) {
View v = container.getChildAt(i);
// perform action on this view
}
Ok, fragment has method getView() :
You can do this like: