

I have followed the instructions and information found in this thread:
Webview load html from assets directory
Which lead me to generate the following code:
The html file, patchnotes.html:
<!DOCTYPE html><html><head> <title>Hi there</title></head><body> This is a page a simple page</body></html>The XML reference to the webveiw I am using:
<WebViewandroid:id="@+id/webview"android:visibility="gone"android:layout_marginLeft="30dp"android:layout_marginTop="220dp"android:layout_width="200dp"android:layout_height="300dp"></WebView>The Java code relevant to displaying the webview:
private void changeLog() {final View newsPanel = (View) findViewById(R.id.newsPanel);final TextView titleChangeLog = (TextView) findViewById(R.id.titleChangeLog);final WebView webview = (WebView) findViewById(R.id.webview);newsPanel.setVisibility(View.VISIBLE);titleChangeLog.setVisibility(View.VISIBLE);webview.setVisibility(View.VISIBLE);toggleMenu(newsPanel);}public class ViewWeb extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);WebView wv;wv = (WebView) findViewById(R.id.webview);wv.loadUrl("file:///android_asset/patchnotes.html");}}I suspect perhaps it is something to do with the class ViewWeb never being called, but there is nothing at all in the example I linked above to suggest that you need to.
What happens when I execute this code is that nothing is displayed. There is no error, it just doesn’t display any of the content of the html file.
Any help here would be greatly appreciated, I am sure it is something simple I am missing.
Thank you.
扫一扫在手机打开