tags:

views:

48

answers:

1

I'm trying to load a html page from the assets directory. I tried this, but it fails.

public class ViewWeb extends Activity {  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        WebView wv;  
        wv = (WebView) findViewById(R.id.webView1);  
        wv.loadUrl("file:///android_asset/aboutcertified.html");   // fails here
        setContentView(R.layout.webview);  
    }  
}

I don't really get any telling errors in LogCat...

A: 

You are getting the WebView before setting the Content view so the wv is probably null.

public class ViewWeb extends Activity {  
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);
            setContentView(R.layout.webview);  
            WebView wv;  
            wv = (WebView) findViewById(R.id.webView1);  
            wv.loadUrl("file:///android_asset/aboutcertified.html");   // fails here
        }  
    }
BrennaSoft
That was it. I had it that way to begin with, tried swapping it, but now it works... Cool.
AndyD273
On a side note, is the white on black a standard look in Android?All my table views are white on black by default, but my html is set for black on white... I can change them, but not sure which one to change.
AndyD273