setActionView(null) 给我这个警告:应用程序可能在其主线程上做了太多工作

setActionView(null) giving me this warning: The application may be doing too much work on its main thread

我试图在我的操作栏中创建一个进度条微调器,但在删除微调器时出现错误:

这是我的代码

  public void setRefreshActionButtonState(final RefreshState state) {
    //new ActionButtonState(state).execute();
    if (optionsMenu != null) {
      final MenuItem refreshItem = optionsMenu
          .findItem(R.id.menuRefresh);
      if (refreshItem != null) {
        if (state == RefreshState.REFRESHING) {
          refreshItem.setActionView(R.layout.progress);
        } else if (state == RefreshState.SUBSCRIPTION_ACTIVE) {
          refreshItem.setActionView(null);
          refreshItem.setIcon(R.drawable.ic_subscription_on_48dp);
        } else {
          refreshItem.setActionView(null);
          refreshItem.setIcon(R.drawable.ic_subscription_off_48dp);
        }
      }
    }

  }

如果我删除 refreshItem.setActionView(null); 或注释掉错误就会消失。

这是我的 progress.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_height="wrap_content"
             android:layout_width="56dp"
             android:minWidth="56dp">
  <ProgressBar android:layout_width="32dp"
               android:layout_height="32dp"
               android:layout_gravity="center"
      android:id="@+id/refreshing_progress"/>
</FrameLayout>

我也尝试使用 AsyncTask 来执行此操作,但遇到了同样的错误。

我的原始教程来自 http://www.michenux.net/android-refresh-item-action-bar-circular-progressbar-578.html

事实证明,我的应用程序中有另一个进程对应于该事件序列并导致了问题。