As per the stacktrace, this is what seems to be causing the issue :
java.lang.NoSuchMethodException: addPlan [interface android.view.MenuItem]
When defining onClick method for a menu item in xml, you should provide a method with the correct name, taking a single MenuItem object as argument. Quoting the docs :
Android 3.0 adds the ability for you to define the on-click behavior for a menu item in XML, using the android:onClick attribute. The value for the attribute must be the name of a method defined by the activity using the menu. The method must be public and accept a single MenuItem parameter—when the system calls this method, it passes the menu item selected
You should include the following method in your Activity code as this will be called by the system when you declare onClick in xml even if you also have onOptionsItemSelected in your code :
public boolean addPlan (MenuItem menuItem){
// Your code here
}
You best bet would probably be to use only onOptionsItemSelected()
, because that method should work on all versions of Android whereas declaring onClick in xml will be ignored for devices running Gingerbread or lower. So as an alternative, you could do this :
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.profile_edit:
addPlan();
return true;
case R.id. menu_main_spinner:
loadPlan();
return true;
}
}
... and remove the onClick declarations from your menu xml.