質問

In my activiy, I open a DialogFragment to insert data in db. When I'm done, i dismiss the dialog, but I would like to change the sync icon of the activity to a red sync icon ( to say the user there is data to sync). The only way I can do is just before I dismiss, call a public method that belongs to the activity from the dialog, but I can't reach the Menu Items How can I do???

役に立ちましたか?

解決

When I close the dialog, I call a method that invoke from the DialogFragment:

invalidateOptionsMenu();

then, it enters in the onPrepare Method :

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem menuSync= menu.findItem(R.id.menu_sync);
    int sincronizado = prefs.getInt("sincronizado", 0);
   if (sincronizado == 1)
       menuSync.setIcon(R.drawable.ic_action_update_red);
    return super.onPrepareOptionsMenu(menu);
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top