我在res/menu/student_marks.xml文件中有我的menuItem:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".StudentMarks" >
<item android:id="@+id/action_selected_year"
android:title="@string/action_selected_year"
android:showAsAction="withText|ifRoom"
style="@style/AppTheme" />
</menu>
现在我需要为这个项目设置一个标题,在我的应用程序的特定部分。
我可以使用以下方法来处理这个特定的项目:
onOptionsItemSelected(MenuItem item)
问题在于我需要在程序的另一个部分中获取项目“action_selected_year”,但不是在该方法中。
我不知道如何获得它。