How to disable menu item from the ASyncTask on android?
-
12-11-2019 - |
سؤال
Trying to do the following (code is in the main activity):
private MenuItem mainMenuSync = null;
public void onCreate(Bundle savedInstanceState) {
...
mainMenuSync = (MenuItem) findViewById(R.id.main_menu_sync);
}
private class Synchronize extends AsyncTask<Void, Void, Void> {
...
@Override
protected void onPreExecute() {
mainMenuSync.setEnabled(false);
}
But it fails. What I am doing wrong? (This menu item really starts this ASyncTask and I would like to avoid starting it again)
لا يوجد حل صحيح
لا تنتمي إلى StackOverflow