I need to send data from one fragment to another and it can't seem to work out. Does anyone have any ideas?
Here are some bits of the code in the MainActivity.kt :
lateinit var movieId: String
fun setMovie(movietitle: String){
this.movieId = movietitle
}
fun getMovie(): String {
return movieId
}
This is in the first fragment:
var movieId: TextView = view.findViewById<EditText>(R.id.TitleId)
(activity as MainActivity).setMovie(movieId.toString())
And this is the fragment where I want to receive the string:
searchMovieByTitle((activity as MainActivity).getMovie())
Is there some other way I can recieve the data?