Write an interface class with object/objects/Data types you need to sync
interface OnSaveClickListener {
fun onSaveClicked(contact: Contact)
}
Now in ContactListFragment class
class ContactListFragment : Fragment(), OnSaveClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activity as AddContactACtivity).mOnSaveClickListener = this
}
override fun onSaveClicked(contact: Contact) {
// Whatever you want to do with the data
}
}
In AddContactActivity,
class AddContactActivity {
var mOnSaveClickListener : OnSaveClickListener? = null
private void whenYouClickSave(contact: Contact){
mOnSaveClickListener?.onSaveClicked(contact)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…