这是我的代码......
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
。我怎样才能做到这一点?
帮助我。
答案 0 :(得分: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);
}
});