How to get child views of a ViewGroup in Android?
10,501
Solution 1
WebView has methods getChildCount()
and getChildAt(int index)
. You can try to use these methods, but better solution is Bixi's one.
Solution 2
Why don't you use findViewById ?
TextView subElement = (TextView) webview.findViewById(R.id.subelement);
subElement.setText("Oh Hi");
If you really want to iterate over the child, you can also use ViewGroup::getChildAt() and ViewGroup::getChildCount()
Author by
Hossein POURAKBAR
Updated on June 04, 2022Comments
-
Hossein POURAKBAR almost 2 years
I have to get child views of WebView. For some text manipulations, I wonder if there is a way to set attributes of child views, for example:
View[] childs = webView.getChilds; View ch = childs[0]; ch.setText("manipulated text");
-
Hossein POURAKBAR over 11 yearsI don't know about inner views, can you write some applied code? Thanks.
-
Jscti over 11 yearsAll you need is in my post, if you need code example : I strongly suggest you to read the Android Training pages : developer.android.com/training/index.html because it's some very basic android methods
-
BORSHEVIK about 8 yearsfindViewById() Is exacting to resources