【发布时间】:2020-05-28 16:24:32
【问题描述】:
我遇到了无法更改样式主题的问题。我想确保每次导航到不同的片段时,应用程序主题都会改变。希望能帮我解决这个问题。提前谢谢你。
class MainKonsesiFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,savedInstanceState: Bundle?): View? {
//create ContextThemeWrapper from the original Activity Context with the custom theme
val context = ContextThemeWrapper(activity, R.style.AppKonsesiTheme)
//clone the inflater using the ContextThemeWrapper
val localInflater = inflater.cloneInContext(context)
val binding:FragmentMainKonsesiBinding = DataBindingUtil.inflate(localInflater,R.layout.fragment_main_konsesi,container,false)
binding.cardInputPemantauan.setOnClickListener(
Navigation.createNavigateOnClickListener(R.id.action_mainKonsesiFragment_to_inputPemantauanFragment)
)
binding.cardListKonsesi.setOnClickListener(
Navigation.createNavigateOnClickListener(R.id.action_mainKonsesiFragment_to_listKonsesiFragment)
)
return binding.root
}
}
【问题讨论】:
标签: android kotlin styles fragment android-architecture-navigation