java - Passing data from activity to fragment transaction.replace() -


i have problem when passing data activity fragment(fragments overlapped): need pass arraylist integer contains id of checkboxes checked...

before passing data: enter image description here

after pass data: enter image description here

code pass data activity fragment:

 bundle bundle = new bundle();     bundle.putintegerarraylist("oki", hm);     system.out.println("pero:" + bundle);      mylistfragment myfragment = new mylistfragment();     myfragment.setarguments(bundle);     fragmenttransaction transaction = getsupportfragmentmanager().begintransaction();     transaction.replace(r.id.container, myfragment);       transaction.commit(); 

code data:

@override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         // inflate custom_spinner_items fragment         //super.ondestroy();         try {         bundle = getarguments();          system.out.println("bundles:" + bundle);         //if (bundle != null) {                   strtext = bundle.getintegerarraylist("oki");                 system.out.println("ah:" + strtext);           //}         }catch(exception e){          } 

in mylistfragment

private arraylist marraylist;  public void setarraylist(arraylist arraylist) {     this.marraylist = arraylist; } 

you can access marraylist anywhere

then do

    bundle bundle = new bundle();     bundle.putintegerarraylist("oki", hm);     system.out.println("pero:" + bundle);      mylistfragment myfragment = new mylistfragment();     myfragment.setarraylist(hm);       fragmenttransaction transaction = getsupportfragmentmanager().begintransaction();     transaction.replace(r.id.container, myfragment);       transaction.commit(); 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -