Android setActionView(null)给我这个警告:应用程序可能在其主线程上做了太多的工作
我正在尝试在actionbar中创建进度条微调器,删除微调器时出错: 这是我的密码Android setActionView(null)给我这个警告:应用程序可能在其主线程上做了太多的工作,android,multithreading,android-runonuithread,Android,Multithreading,Android Runonuithread,我正在尝试在actionbar中创建进度条微调器,删除微调器时出错: 这是我的密码 public void setRefreshActionButtonState(final RefreshState state) { //new ActionButtonState(state).execute(); if (optionsMenu != null) { final MenuItem refreshItem = optionsMenu .fin
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来完成这项工作,但也遇到了同样的错误
我从中获得了我的原始教程,结果是我的应用程序中有另一个进程,对应于事件序列并导致问题。结果是我的应用程序中有另一个进程,对应于事件序列并导致问题