Kotlin with Fragments -
var bundle : bundle ? =null bundle?.putstring("text",text) if (build.version.sdk_int >= build.version_codes.m) { frag = fragment.instantiate(context,fragment2::class.java.name) fragment2 } frag?.arguments=bundle fragmentmanager.begintransaction().replace(r.id.contentpanel1,frag).commit()
i have written these code on fragment1 , passing data it
on fragment 2 receving bundle null can solve it
var bundle : bundle ? bundle = arguments if (build.version.sdk_int >= build.version_codes.m) { toast.maketext(context,bundle.tostring(),toast.length_long).show() }
issue don't initialize var of bundle.look below.
val bundle = bundle() bundle.putstring("text",text) if (build.version.sdk_int >= build.version_codes.m) { frag = fragment.instantiate(context,fragment2::class.java.name) fragment2 } frag?.arguments=bundle fragmentmanager.begintransaction().replace(r.id.contentpanel1,frag).commit()
Comments
Post a Comment