【发布时间】:2012-10-24 11:26:50
【问题描述】:
我必须获得 WebView 的子视图。对于一些文本操作,不知有没有办法设置子视图的属性,例如:
View[] childs = webView.getChilds;
View ch = childs[0];
ch.setText("manipulated text");
【问题讨论】:
标签: android view android-webview viewgroup
我必须获得 WebView 的子视图。对于一些文本操作,不知有没有办法设置子视图的属性,例如:
View[] childs = webView.getChilds;
View ch = childs[0];
ch.setText("manipulated text");
【问题讨论】:
标签: android view android-webview viewgroup
WebView 有方法getChildCount() 和getChildAt(int index)。您可以尝试使用这些方法,但更好的解决方案是Bixi的。
【讨论】:
你为什么不使用 findViewById ?
TextView subElement = (TextView) webview.findViewById(R.id.subelement);
subElement.setText("Oh Hi");
如果你真的想迭代孩子,你也可以使用ViewGroup::getChildAt()和ViewGroup::getChildCount()
【讨论】: