OK. Have been trying for two weeks to get a simple web page I created in FrontPage (test.htm) to load into my Activity in my Eclipse Emulator. I have placed my page (test.htm) into my 'assets' folder and created the VERY simple code below. I STILL cannot get the page to load into my Emulator. I am using an XML with WebView within a Linear Layout (myxmlfile). Does anybody see anything blatantly wrong?? I have also tried: file:///asset/test.htm but my assets folder is asset(s) with an 's'.
public class Activity5 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.m开发者_运维问答yxmlfile);
WebView x = (WebView) findViewById(R.id.webview);
x.loadUrl("file:///assets/test.htm");
}
}
Please HELP!
Do you have to add this uses permission
<uses-permission android:name="android.permission.INTERNET"/>
into your AndroidManifest.xml ?
I think your html path is not correct. It must be android_asset
instead of asset
:
x.loadUrl("file:///android_asset/test.htm");
精彩评论