Skip to content

Instantly share code, notes, and snippets.

@Reacoder
Created July 29, 2014 07:59
Show Gist options
  • Save Reacoder/12e670e7cbb98124ad05 to your computer and use it in GitHub Desktop.
Save Reacoder/12e670e7cbb98124ad05 to your computer and use it in GitHub Desktop.
fragment 中显示action button。
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:musictube="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_play"
android:icon="@drawable/btn_all_actionbar_play"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="@string/action_play"
musictube:showAsAction="always|withText"/>
</menu>
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
mContext = getActivity();
initDb();
View view = inflater.inflate(R.layout.frag_main_mymusic, null);
init(view);
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.mymusic_playlist, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_add) {
showNewPlaylistDialog();
return true;
}
return super.onOptionsItemSelected(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment