我必须加载这些通过使用下面的代码。但最终显示空白屏幕作为输出。您可以检查url
代码之间的链接位于last line
.
WebPagerLoader.java:
public class WebPageLoader extends Activity
{
final Activity activity = this;
private String html;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle(R.string.app_name);
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
webView.loadUrl("<iframe src=\"http://files.flipsnack.com/iframe/embed.html?hash=fdk843nc&wmode=window&bgcolor=EEEEEE&t=1381431045\" width=\"640\" height=\"385\" seamless=\"seamless\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>";
}
}
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.webpageloader"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.webpageloader.WebPageLoader"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
最后我得到了blank screen
.我不知道我做了什么wrong in webView.loadUrl
。
我不知道如何解决这些问题。任何人都可以帮助我解决这些问题。谢谢。
改变你的
webView.loadUrl("<iframe src=\"http://files.flipsnack.com/iframe/embed.html?hash=fdk843nc&wmode=window&bgcolor=EEEEEE&t=1381431045\" width=\"640\" height=\"385\" seamless=\"seamless\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>";
to
webView.loadDataWithBaseURL(null, "<iframe src=\"http://files.flipsnack.com/iframe/embed.html?hash=fdk843nc&wmode=window&bgcolor=EEEEEE&t=1381431045\" width=\"640\" height=\"385\" seamless=\"seamless\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\"></iframe>", "text/html", "UTF-8", null);
The loadDataWithBaseURL()
除其他参数外,该方法还采用解析 HTML 中的相对 URL 时要使用的“基本 URL”。任何相对 URL(例如 )都将被解释为相对于提供给 loadDataWithBaseURL() 的基本 URL。如果您发现内容无法使用 loadData() 正确加载,请尝试使用 null 基本 URL 的 loadDataWithBaseURL() ,因为有时由于未知原因,这种方法效果更好。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)