How to add action bar to a DialogFragment
? I found a way to style an activity to the way we require and then display it as a dialog as in the following link ActionBar in a DialogFragment I need to set an action bar on a proper DialogFragment
. Is it possible?
相关问题
- Customizing android DialogFragment
- Display icon and title in the ActionBar in Android
- DialogFragment - setting initial values and retain
- Managing Action Bar titles when using fragments an
- Item title not displayed in portrait with SHOW_AS_
As Up ActionBar action on DialogFragment indicates: There is no way to attach an ActionBar to the DialogFragment even though you can set the theme of the DialogFragment it will not register as a ActionBar to it, Dialog.getActionBar() will always return null.
But there's always the cases that I really want to use DialogFragment(which contain ActionBar like style) instead of Activity. Just add a Layout that will look like an ActionBar into the DialogFragment's Layout
the following is the steps: 1) DialogFragment layout: about_dialog.xml
2) Implement a ActionBar like layout: fake_action_bar_with_backbotton.xml
Note: the @drawable/ic_menu_back is copied from sdk\platforms\android-21\data\res\drawable-hdpi
3) Update the DialogFragment code
Wish it can help!