How can I get the context in a fragment?
I need to use my database whose constructor takes in the context, but getApplicationContext()
and Fragmen
Inside fragment for kotlin sample would help someone
textViewStatus.setTextColor(ContextCompat.getColor(context!!, R.color.red))
if you use databinding;
bindingView.textViewStatus.setTextColor(ContextCompat.getColor(context!!, R.color.red))
Where bindingView is initialized in onCreateView like this
private lateinit var bindingView: FragmentBookingHistoryDetailBinding
bindingView = DataBindingUtil.inflate(inflater, R.layout.your_layout_xml, container, false)