0

创建了一个功能,当用户点击图片缩略图时,通过调用该WebView.loadurl(String.format())方法加载主图片,然后将所选图片上传并显示给用户查看。但是,在这种情况下,当用户单击图像缩略图时,会显示以下消息:

在此服务器上找不到请求的 URL /projectname_uat/data/images/property/property_id/360/1/index.htm。

在那种情况下出了什么问题?

此外,当我将以下 url 复制到网络浏览器中时:Google Chrome,它最初没有显示,但是当我进行以下更改时,图像显示在网络浏览器中,但没有显示在应用程序设备上。我所理解的是,htm 和 html 之间没有区别,并且大多数可以显示的图像都是 htm 或 html。

我所做的以下更改是将htm更改为html:

/projectname_uat/data/images/property/property_id/360/1/index. html

有人可以为这个问题提供任何帮助吗?这几天一直困扰着我,而且越来越令人沮丧。提前致谢。

代码:

int img_id = 1;
photoPb = (ProgressBar) findViewById(R.id.photoPb);
    photoPb.setVisibility(View.INVISIBLE);
    webView = (WebView) findViewById(R.id.webview01);
    webView.getSettings().setJavaScriptEnabled(true);
    //webView.getSettings().setPluginsEnabled(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(getContext(), description, Toast.LENGTH_SHORT).show();
        }
    });
 if (panoSize > 0) {
        g = (Gallery) findViewById(R.id.gallery01);
        g.setAdapter(new ImageAdapter());
        int pad = 15;
        g.setSpacing(1);
        g.setUnselectedAlpha(255);
        g.setPadding(pad, 10, pad, pad);
        g.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                img_id = position;
                setImageShade(position);
                captionText.setText(caption[position]);
                Log.i("PropertyPanoramaActvity:if(panoSize>0)","******webView.loadUrl******"+getString(R.string.app_360_domain)+getString(R.string.app_360_property)+(getIntent().getIntExtra("propertyId", 0))+getString(R.string.app_360_directory)+(img_id)+getString(R.string.app_360_index));
                //webView.loadUrl(String.format("https://developer.dapoltd.com/spacetobe_uat/data/images/property/property107/360/4/index.htm", id, img_id));
                webView.loadUrl(String.format(getString(R.string.app_360_domain)+getString(R.string.app_360_property)+(getIntent().getIntExtra("propertyId", 0))+getString(R.string.app_360_directory)+(img_id)+getString(R.string.app_360_index)));


            }
        });
    }

字符串.XML:

<string name="app_360_domain">https://developer.dapoltd.com/spacetobe_uat/</string>
<string name="app_360_property">data/images/property/property</string>
<string name="app_360_directory">/360/</string>
<string name="app_360_index">/index.htm</string>
4

3 回答 3

0

真的很难说为什么它没有显示图像,但我现在认为是我在反斜杠中的问题。尝试这个:

1)

String urlToLoad = String.format(getString(R.string.app_360_domain) + getString(R.string.app_360_property)+(getIntent().getIntExtra("propertyId", 0))+getString(R.string.app_360_directory)+(img_id)+getString(R.string.app_360_index);

2)然后去调试,检查urlToLoad值是否在浏览器中打开。3)如果不是 '@' 必须在 url 的开头添加,以便编译器理解反斜杠是 url 的一部分,而不是转义符号

于 2015-01-15T08:54:16.307 回答
0

您没有将app_360_index字符串值更改为/index.html

于 2015-01-15T08:28:22.200 回答
0

尝试使用:

webView.loadUrl( ""+getString(R.string.app_360_domain)+getString(R.string.app_360_property)+(getIntent().getIntExtra("propertyId", 0))+getString(R.string.app_360_directory)+(img_id++)+getString(R.string.app_360_index));
于 2015-01-15T08:35:06.340 回答