【问题标题】:Kotlin custom actionbar title sometimes shows wrong title for split secondKotlin 自定义操作栏标题有时会在一瞬间显示错误的标题
【发布时间】: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


    【解决方案1】:

    原来我可以只编辑navigation.xml中的标签来省去很多麻烦

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 2020-11-23
      • 2015-06-09
      相关资源
      最近更新 更多