gpt4 book ai didi

android webview客户端 Activity 指示器

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:15:58 24 4
gpt4 key购买 nike

我得到了在 WebView 中显示 Activity 指示器的代码。我检查了不止一个引用资料,但仍然无法正常工作。你能帮我调试下面的代码吗?

Activity 指示器未随以下代码一起提供

protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
final BaseActivity MyActivity = ReviewWebActivity.this;
setContentView(R.layout.review_web);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
Window.PROGRESS_VISIBILITY_ON);


ScannedProduct product = getReviewUrl();
reviewUrl = product.getReviewLink();

if (reviewUrl == null) {
String err = product.getErrorCode();
if(err.equals("")) err ="No Data Available for this product";
Toast.makeText(getApplicationContext(),
"No Data Available for this product", 1).show();
return;
}

webReview = (WebView) findViewById(R.id.webReview);
webReview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Make the bar disappear after URL is loaded, and changes
// string to Loading...
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 1000); // tried with 100 also


}
});
webReview.setWebViewClient(new ReviewWebClient());
webReview.getSettings().setJavaScriptEnabled(true);

webReview.loadUrl(reviewUrl);
}

最佳答案

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class SandbarinFacebook extends Activity {
WebView mWebView;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...",true);

mWebView = (WebView) findViewById(R.id.webkitWebView1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if(pd!=null && pd.isShowing())
{
pd.dismiss();
}
}
});
mWebView.loadUrl("http://www.yahoo.co.in");
setTitle("Yahoo!");
}
}

关于android webview客户端 Activity 指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9310784/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com