用户应该能够在点击图像缩略图时查看图像,但是,所有显示的图像都是带有刷新按钮的白色屏幕。对于所有选择的图像,行为是一致的,WebView方法已在以下实现中使用。我试图调整宽度和高度布局,因为我怀疑图像的尺寸超出范围,以便在Android设备中显示。但是,整改实施也没有奏效。出了什么问题?有什么建议?
我已附上以下代码副本供您阅读:
代码:
webView = (WebView) findViewById(R.id.webview01);
webView.setBackgroundColor(0x00000000);
webView.getSettings().setJavaScriptEnabled(true);
//webView.getSettings().setPluginState(PluginState.ON);
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setSupportMultipleWindows(false);
webView.getSettings().setSupportZoom(false);
webView.invalidate();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
webView.getSettings().setUseWideViewPort(true);
webView.setInitialScale(1);
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(getContext(), description, Toast.LENGTH_SHORT).show();
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
// TODO Auto-generated method stub
super.onProgressChanged(view, newProgress);
photoPb.setProgress(newProgress);
if (newProgress != 100) {
photoPb.setVisibility(View.VISIBLE);
} else {
if (apb == null)
apb = new BgPbAsyncTask().execute();
else if (apb.getStatus() != AsyncTask.Status.RUNNING
&& apb.getStatus() != AsyncTask.Status.PENDING)
apb = new BgPbAsyncTask().execute();
}
}
});
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+1;
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(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)));
/*if (flashInstalled) {
webView.loadUrl(img[position].getPanoUrl());
} else {
webView.loadUrl(String.format("https://developer.dapoltd.com/spacetobe_uat/data/images/property/property107/360/4/index.htm", id, img_id));
//webView.loadUrl(getString(R.string.wap_domain) + getString(R.string.wap_flashnotsupported));
}*/
}
});
}
Android Manifest
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
</uses-permission><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
XML布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical" android:background="@color/transparent">
<include layout="@layout/header" />
<include layout="@layout/property_nav" />
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dp"
android:background="@color/transparent">
<include layout="@layout/property_share" />
</RelativeLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingRight="10dp"
android:paddingLeft="10dp" android:layout_weight="1" android:orientation="vertical">
<WebView android:id="@+id/webview01" android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="4"></WebView>
<ProgressBar android:id="@+id/photoPb" android:layout_width="fill_parent" android:layout_height="5dp"
style="@android:style/Widget.ProgressBar.Horizontal" />
</LinearLayout>
<TextView
android:id="@+id/caption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white" />
<Gallery android:id="@+id/gallery01" android:layout_width="fill_parent" android:layout_height="wrap_content" />
<include layout="@layout/mainmenu" />