How to pass and get value from fragment and activity?
use this to send arguments to fragment
fun newInstance(index: Int): MyFragment {
val f = MyFragment ()
// Pass index input as an argument.
val args = Bundle()
args.putInt("index", index)
f.setArguments(args)
return f
}
And get those arguments like this
val args = arguments
val index = args.getInt("index", 0)