【发布时间】:2019-11-06 13:59:18
【问题描述】:
我为我的 kotlin 应用程序中的每个片段创建了自定义操作栏标题。但是有时它会在显示自定义标题之前显示片段名称。
这是我在每个片段中的代码:
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val binding = inflate<FragmentHomeBinding>(
inflater,
R.layout.fragment_home, container, false
)
////
//some binding
////
return binding.root
}
override fun onAttach(context: Context) {
super.onAttach(context)
(activity as AppCompatActivity).supportActionBar?.title = "Custom"
}
override fun onResume() {
super.onResume()
(activity as AppCompatActivity).supportActionBar?.title = "Custom"
}
【问题讨论】:
标签: android-fragments kotlin android-actionbar