我想通過我的Android應用程序中的Web視圖顯示微件部件。我生成一個widget和定製它一點點WebView不顯示微件Widget
<div style='padding-left: 100px;'><a class="twitter-timeline"
href="http://twitter.com/%s"
data-widget-id="<number>"
data-screen-name="%s"
data-chrome="nofooter noborders noheader transparent"
data-related="benward,endform">
<FONT COLOR="FFFFFF">Tweets by @%s</a>
<script>
!function(d,s,id)
{
var js,fjs=d.getElementsByTagName(s)[0],
p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id))
{
js=d.createElement(s);
js.id=id;
js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}
}(document,"script","twitter-wjs");</script>
我編程方式從資產加載:
WebView webView = (WebView) view.findViewById(R.id.webview);
webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
webView.getSettings().setJavaScriptEnabled(true);
webView.setBackgroundColor(Color.BLACK);
webView.getSettings().setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.e(IrisDelegate.TAG, description);
}
});
try {
StringBuilder builder = new StringBuilder();
InputStream is = getActivity().getAssets().open("twitter.html");
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = "";
while ((line = reader.readLine()) != null) {
builder.append(line);
}
String twitter = getArguments().getString(TWITTER);
String data = String.format(builder.toString(), twitter, twitter, twitter);
webView.loadData(data, "text/html", HTTP.UTF_8);
但不幸的是它不;噸的工作,我看到的只是鏈接到的網頁我的推特用戶。你知道問題在哪裏嗎?
謝謝,但它沒有幫助只顯示飼料清單 –