这段代码加载的网页不是本地工作正常,但当我把本地文件存在错误:文件未找到。 我使用cocos2dx和file.java包含活动我有一个功能,使:Android加载本地html文件并在网页浏览器中显示
File file=new File("/android_asset/iCD_credits_it.html");
Uri uri = Uri.fromFile(file);
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setDataAndType(uri, "text/html");
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
//browserIntent.setData(uri);
me.startActivity(browserIntent);
我已经把iCD_credits_it在资源文件夹中,我可以看到它在Eclipse 的资产文件夹我怎样才能在浏览器中显示该网页? 谢谢
我试过这个:\t Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(“file:///assets/iCD_credits_it.html”)); i.setClassName(“com.android.browser”,“com.android.browser.BrowserActivity”); me.startActivity(i); – sefiroths
@sefiroths:这不是我在答案中概述的解决方案之一,而且您可能发现它不起作用。 – CommonsWare
其实它没有工作......我认为这可能只是因为它是错误的路径...然而 如何添加webview而不添加xml在cocos2dx图层的顶部?添加一个按钮只能测试不工作: \t LinearLayout layout = new LinearLayout(me); layout.setOrientation(LinearLayout.VERTICAL); //也可以通过android在xml中完成:orientation =“vertical” ... – sefiroths