Android - Can't hide progress bar

后端 未结 4 978
误落风尘
误落风尘 2021-01-21 05:19

So I\'ve checked the other questions to hide a progress bar but all seem to suggest doing what I\'m already doing.

I\'m trying to use

mProductListProgres         


        
相关标签:
4条回答
  • 2021-01-21 05:35

    I don't know how your code is written but had similar problem and resolved by removing the view object from declaration

    like

    mProductListProgressBar = (ProgressBar) mRoot.findViewById(R.id.product_list_progressbar);
    

    should be

    mProductListProgressBar = (ProgressBar) findViewById(R.id.product_list_progressbar);
    

    Try it and check

    Reason is the progress bar is on the top of every view in the hierarchy and it's not belong to any root view.

    0 讨论(0)
  • 2021-01-21 05:40

    The problem with this behaviour usually happens when your view which you try to hide is needed / referenced by someone else.

    In your case, as you mentioned in the comments, you use mProductListProgressBar for setEmptyView() of your GridView.

    Another possibility of running into similar troubles when there other views in your relative container layout which set their position relatively to your mProductListProgressBar. This setting could be either in the code or in .xml.

    Please make sure you don't have any of above and View.GONE should work fine.

    As for setEmptyView() - it is only used to show something meaningful to the user when your adapter is empty. I recommend just setting up simple Layout for that with, say, TextView "no items", in the middle, and pass it to setEmptyView()

    Hope that helps.

    0 讨论(0)
  • 2021-01-21 05:41

    A solution that worked for me was to hide the view in XML:

    android:visibility="gone"

    and then unhide/hide it at runtime when needed:

    yourProgressBar.setVisibility(View.VISIBLE) // or View.VISIBLE depending on situation

    0 讨论(0)
  • 2021-01-21 05:47

    I know that it is an old question. But I just spent a lot of time debugging similar situation. I could not hide ProgressBar on top of unityPlayer view.

    One more thing to ensure is that You are hiding it while in UI thread.

    To ensure surround Your UI code with:

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                loadingIndicator.setVisibility(View.GONE);
            }
        });
    
    0 讨论(0)
提交回复
热议问题