我必須得到WebView的子視圖。對於一些文本操作,我不知道是否有設置的子視圖屬性的方式,例如:如何在Android中獲取ViewGroup的子視圖?
View[] childs = webView.getChilds;
View ch = childs[0];
ch.setText("manipulated text");
我必須得到WebView的子視圖。對於一些文本操作,我不知道是否有設置的子視圖屬性的方式,例如:如何在Android中獲取ViewGroup的子視圖?
View[] childs = webView.getChilds;
View ch = childs[0];
ch.setText("manipulated text");
你爲什麼不使用findViewById?
TextView subElement = (TextView) webview.findViewById(R.id.subelement);
subElement.setText("Oh Hi");
如果你真的想遍歷孩子,你還可以使用ViewGroup::getChildAt()和ViewGroup::getChildCount()
的WebView有方法getChildCount()
和getChildAt(int index)
。你可以嘗試使用這些方法,但更好的解決方案是碧溪的方法。
我不知道內部的意見,你可以寫一些應用程序代碼?謝謝。 –
如果您需要代碼示例,我需要的僅僅是在我的文章中:我強烈建議您閱讀Android培訓頁面:http://developer.android.com/training/index.html,因爲它是一些非常基本的Android方法 –
* * findViewById()**是嚴格的資源 – BORSHEVIK