Iterating through children ViewGroup using RxJava
I am new to RxJava.
I based this solution to iterate through each child ViewGroup
:
LinearLayout layout = (LinearLayout) findViewById(R.id.my_layout);
for (int i = 0; i < layout.getChildCount(); i++) {
View child = layout.getChildAt(i);
child.setEnabled(false);
}
but I was unable to convert it to RxJava.
Can someone please give me a hint with the description?
Thanks in advance.
+3
source to share
1 answer
ok when i read Reactive Documentaion i found range
operator, the answer i came up with looks like this:
Observable.range(0, layout.getChildCount())
.map(layout::getChildAt)
.subscribe(child -> child.setEnabled(false));
+2
source to share