문제

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