I am trying to get a link to a menu item, but I just can't. All this inside the fragment.
Menu: boat_accept_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.toolbar.MainActivity" >
<item
android:id="@+id/done_boat_select"
android:title="@string/done_C"
app:showAsAction="always"/>
</menu>
You can see the comment inside the code, I can not get the link.
the code:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
getActivity().getMenuInflater().inflate(R.menu.boat_accept_menu, menu);
if (boatClassSelectedBtn == null) {
Log.e("boatClassSelectedBtn", "NULL!");
}
else
{
Log.i("boatClassSelectedBtn", "OK!");
}
}
What is the problem? How to achieve this?
source
share