1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| class CommentDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setStyle(DialogFragment.STYLE_NORMAL, R.style.DialogFragmentTheme) }
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater?.inflate(R.layout.fragment_show_comment, container, false) }
companion object { fun show(fragmentManager: FragmentManager) { val ft = fragmentManager.beginTransaction() val prev = fragmentManager.findFragmentByTag(CommentDialogFragment::class.java.simpleName) if (prev != null) { ft.remove(prev) } ft.addToBackStack(null) val newFragment = CommentDialogFragment() newFragment.show(ft, CommentDialogFragment::class.java.simpleName)
} } }
|