I have an activity for creating new item for listView. On click Save button of this activity , I want to add date to arrayList. This arrayList is in another activity and this activity has a listView and its adapter gets items from arrayList
This is my adapter :
inner class mo3d1Adapter : BaseAdapter {
override fun getItemId(p0: Int): Long {
return p0.toLong()
}
override fun getCount(): Int {
return listOfmo3d.size
}
var listOfmo3d = ArrayList<mo3dInfo>()
var context: Context? = null
constructor(context: Context, listOfmo3d: ArrayList<mo3dInfo>) : super() {
this.listOfmo3d = listOfmo3d
this.context = context
}
override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
val mo3d = listOfmo3d[p0]
var inflatormo3d = context!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
var myViewmo3d = inflatormo3d.inflate(R.layout.item_mo3d, null)
myViewmo3d.setOnClickListener() {
Toast.makeText(context, " click" , Toast.LENGTH_SHORT).show()
var intent = Intent(context, mo3dDetails::class.java)
startActivity(intent)
}
myViewmo3d.meeting_time_mo3d.text = mo3d.time.toString()
myViewmo3d.meeting_name_mo3d.text = mo3d.name.toString()
// myViewmo3d .meeting_time.text = mo3d .time.toString()
myViewmo3d.meeting_date_mo3d.text = mo3d.date.toString()
// myViewmo3d.attendance_number_.text = mo3d.n2.toString()!!
return myViewmo3d
}
override fun getItem(p0: Int): Any {
return listOfmo3d[p0]
}
}
This is my arrayList :
var listOfmo3d = ArrayList<mo3dInfo>()
This is on click save button function :
fun SaveAction(view: View) {
var i = MainMo3d()
i.listOfmo3d.add(mo3dInfo("f", "test", "test"))
}
How can I pass data from activity to another activity and add it to arrayList ?