1

これは私のコードです...

public class detailedview extends Activity
{
    WebView mWebView;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detailedview);
        GetSet gs = new GetSet();

        String title = gs.getTitle();
        String desc = gs.getDesc();

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);
        mWebView.getSettings().setTextSize(TextSize.SMALLER);
        mWebView.loadDataWithBaseURL("", "<p  align=\"justify\"><b> " + title+"</p></b><p align=\"justify\"><br>"+ desc + "</p></br>", "text/html", "utf-8", "");

ProgressBarに を設定したいActivity。どうすればこれを達成できますか?助けて。

4

1 に答える 1

1

以下のコードは、進行状況バーを表示するために使用されます。

ProgressDialog progressDialog = ProgressDialog.show(this, "Please Wait!", "Loading...");

無効にするには:

if (progressDialog != null) {
            progressDialog.dismiss();
    }

アップデート:

this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.main);
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
                Window.PROGRESS_VISIBILITY_ON);
        final WebView webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("file:///android_asset/www/index.html");
        final Activity MyActivity = this;
        webView.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 * 100); // Make the bar
                                                        // disappear after URL
                                                        // is loaded

                // Return the app name after finish loading
                if (progress == 100)
                    MyActivity.setTitle(R.string.app_name);
            }
        });
于 2012-05-30T12:15:36.453 に答える