i have one fragment that displays list with help of adapter.in list there is a link click in which user calls another activity that calls an adapter to get data .After getting data we can add ata and save in that adapter this directs user to fragment 1 to save data .
.initially I don't want menu as save in fragment1. Once the user add data in onclick of the list which opens another list to add data and returns to fragment1 then I need to display menu save.....I have tried.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.action_save, menu);
shareItem = menu.findItem(R.id.action_save1);
shareItem.setVisible(false);
}
Later based on condition I am doing: shareItem.setVisible(true);