装载纺车动画纺车、动画

2023-09-06 13:20:38 作者:情丝斩不断ギ笙箫凌乱

我在做一个搜索和填充一个ListView有结果,因为他们来。在顶部有一个酒吧与文本正在搜索...我想一个小纺车动画添加了酒吧右侧角球,表明这项工作正在做的用户。

I'm doing a search and populating a listview with results as they come. On top there's a bar with the text "Search in progress... " I'd like to add a small spinning wheel animation to the bar in the right corner, to show the user that work is being done.

您可以看到在画廊的应用程序,这纺车在右上角时被加载缩略图。此外,相同的动画显示在天文文件管理器,当文件被列在目录,(再次右上角)。

You can see this spinning wheel in the gallery app in the top right corner when thumbnails are being loaded. Also, the same animation is shown in Astro File Manager, when files are being listed in a directory, (again top right corner).

我如何把它放在那里?

推荐答案

您需要调用 requestWindowFeature 的onCreate 的setContentView

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.search_screen);

和假设你使用的AsyncTask 用于填充列表

And Assuming you're using AsyncTask for Populating the list

在preExecute()将调用 setProgressBarIndeterminateVisibility(真);

onPostExecute()将调用 setProgressBarIndeterminateVisibility(假);