This is a Kotlin way of doing this, I have created button in fragment layout and then set onClickListner in onViewCreated.
according to @Viswanath-Lekshmanan comment
override fun onViewCreated(view: View?, savedInstanceState: Bundle?)
{
super.onViewCreated(view, savedInstanceState)
btn_FragSP_back.setOnClickListener {
activity?.onBackPressed()
}
}