I am having list of Colleges to display and click the perticular college it goes to the detail page. In there there is a menu bar with notification and `Favourite_icon`.Here i am having the `Favourite_icon` and `Favourite_icon1`. If users clcik the `favourite_icon` it stored as favourited in server and the icon changed as `Favourite_icon1`. After do some process i have visted the Favourited college. That time it should show the `Favourite_icon1` in menu bar. I have tried the following method but nothing happend . I have added the the code which i have tried

menu\_clg.xml

```
<?xml version="1.0" encoding="utf-8"?>
<menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:appmunu="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".UserDashBoardFragment">
    <item
        android:id="@+id/action_notify"
        android:icon="@drawable/mail_icon"
        appmunu:showAsAction="always"
        android:title="Notification" />
    <item
        android:id="@+id/action_favourite"
        android:icon="@drawable/icon_selector"
        appmunu:showAsAction="always"
        android:title="Favourite" />
</menu>

```

this Activity code

```
private boolean canAddItem;

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_clg, menu);
        mMenu = menu;
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
            case R.id.action_notify:
                navigatetoNotification();
                return true;
            case R.id.action_favourite:
                if (item.getItemId() == R.id.action_favourite) {
                    invalidateOptionsMenu();
                    favouriteClg();
                }
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {

        if (canAddItem) {
            menu.getItem(1).setIcon(R.drawable.vijay);
            canAddItem = false;
            favouriteClg();
        } else {
            menu.getItem(1).setIcon(R.drawable.favourite_icon);
            canAddItem = true;
            favouriteClg();
        }

        return super.onPrepareOptionsMenu(menu);
    }

```

this is the code for check wheather the college is already favourited or not in `onCreate()` method

```
  public void chechFavourite() {
                new AsyncTask<Void, Void, String>() {
                    @Override
                    protected String doInBackground(Void... arg0) {
                        //method name changed here
                        //getAllEventFromUser method used for getting all previously send events of current user

                        return favouriteDelegates.getAllCollegeDetails(userMO, context);
                    }

                    @Override
                    protected void onPostExecute(String collegelists) {

                        if (collegelists != "null") {
                            initCollegeMO = gson.fromJson(collegelists, new TypeToken<InitCollegeMO>() {
                            }.getType());
                            collegeMOs = initCollegeMO.getCollegeMOs();
                            for (CollegeMO collegeMO1 : collegeMOs) {
                              //here the list of college has eceived from server so i checked all the college id with current college id
                                collegeId = collegeMO1.getCollegeId();                            //here collegeMO isthe object which is accessed by parcelable from another activity
                                if (collegeMO.getCollegeId() == collegeId) {
                                    canAddItem = true;

                                } else {
                                    canAddItem = false;

                                }
                            }
                        } else {
                            canAddItem = false;

                        }
                    }
                }.execute(null, null, null);
            }
        }

```