Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自服务器的Android Webview index.html从本地加载xxx.jpg_Android_Android Webview_Local Storage_Assets - Fatal编程技术网

来自服务器的Android Webview index.html从本地加载xxx.jpg

来自服务器的Android Webview index.html从本地加载xxx.jpg,android,android-webview,local-storage,assets,Android,Android Webview,Local Storage,Assets,我必须从服务器加载一个page index.php。我不想从项目中的资产文件夹加载本地文件,但它不起作用 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_PROGRESS); final Activity _activity = this;

我必须从服务器加载一个page index.php。我不想从项目中的资产文件夹加载本地文件,但它不起作用

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    final Activity _activity = this;

    setContentView(R.layout.main);

    webview = (WebView) findViewById(R.id.webview);

    webview.setWebViewClient(new myWebViewClient());

    webview.getSettings().setRenderPriority(RenderPriority.HIGH);
    webview.getSettings().setJavaScriptEnabled(true);

    webview.getSettings().setAllowFileAccess(true);
    webview.getSettings().setAppCacheEnabled(false);
    webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

    webview.loadUrl("http://192.168.0.11/mypage.php");

            webview.setWebViewClient(new myWebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon)      {
            // TODO Auto-generated method stub
            super.onPageStarted(view, url, favicon);
            progressBar.show();
        }

        @Override
        public void onReceivedError(WebView view, int errorCode,
                String description, String failingUrl) {
            // TODO Auto-generated method stub
            super.onReceivedError(view, errorCode, description, failingUrl);

        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // TODO Auto-generated method stub
            super.onPageFinished(view, url);
            progressBar.dismiss();
        }
    });
    }
在我的HTML页面中,一些本地图像的加载方式如下:

<img src="file:///android_asset/image.jpg" width="200">
但图像不显示

你知道吗

谢谢


André。

无需给出从文件到资产的完整路径。如果要显示的html文件和图像都位于资产目录的同一目录中,请给出文件名

<img id="loadimage" src="ic_launcher.png" height="100px" width="100px" />

ic_launcher.png文件位于资产文件夹中

请检查您的图像名称和名称。分机是.jpg,你确定吗?同时也删除宽度和测试它!!!图片延伸是正确的,我已经检查了没有大小。。。不起作用。