Put a progress spinner in a SearchView?

前端 未结 3 1322
梦如初夏
梦如初夏 2021-01-01 06:03

I\'m using a SearchView in my Activity. As the user types, I am performing search requests to a server. I want to indicate that some activity is happening. Is it possible to

3条回答
  •  一个人的身影
    2021-01-01 06:23

    I know that it is not within the SearchView, but this is by far the simplest method to provide progress indication in the ActionBar found here http://blog.denevell.org/android-progress-spinner.html:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.activity_main);
    
        // Turn it on
        setProgressBarIndeterminateVisibility(true);
        // And when you want to turn it off
        setProgressBarIndeterminateVisibility(false);
    }
    

    If you really want the progress to appear inside the SearchView, I would assume that you could use a FrameLayout instead of LinearLayout (or atleast as a parent), putting the progress in bottom of the XML (which will place it on top of the SearchView).

提交回复
热议问题