【问题标题】:Android hiding the title bar after progress bar finishes loadingAndroid在进度条加载完成后隐藏标题栏
【发布时间】:2012-08-06 03:18:41
【问题描述】:

我试图在进度条加载完成后隐藏标题栏。谁能告诉我它是怎么做的?谢谢

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        //this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); **//Putting this make the whole title bar hidden**
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        this.getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

        setContentView(R.layout.main);

一堆代码……

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)

             this.requestWindowFeature(Window.FEATURE_NO_TITLE);**//Not Working (shows Error The method requestWindowFeature(int) is undefined for the type new WebChromeClient(){} )**  
              //MyActivity.setTitle(R.string.app_name);

              }



            });
        webView.setWebViewClient(new InsideWebViewClient());


    }

【问题讨论】:

  • 当我实现该代码 AndroidRuntimeException: requestFeature() 必须在添加内容之前调用时出现此错误

标签: android progress-bar titlebar android-titlebar


【解决方案1】:

您需要将以下语法写入您的 AndroidManifest.xml 文件中

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

如果您想通过 Activity 中的编码来实现,那么您可以在 Activity 的 OnCreate() 方法中使用以下代码。

requestWindowFeature(Window.FEATURE_NO_TITLE); 
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

【讨论】:

  • 感谢路西法的回复。但是这样做会隐藏我的进度条,使其不会显示在我的标题栏上。您是否还有其他选项可以在 webview 加载完成后显示进度条并隐藏标题栏?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-16
  • 1970-01-01
相关资源
最近更新 更多