java - sending multiple data from one fragment to another fragment -


in app..one mainactivity..two fragment fragment , fragmentb.. created..and added 2 edittext in fragmenta..i want send edittext data framentb..and reuse itin..fragmentb..how this... should use interface concept..or..is concept..

    public class fragmenta extends fragment  {       button nextt;        edittext number;        edittext alpha;        }          @override          public void onstart() {           super.onstart();            fm = ((mainactivity) context).getfragmentmanager();       }        @override        public void onclick(view view) {           int viewid = view.getid();           fragmenttransaction ft;           ft = fm.begintransaction();          fragmentb fragmentb = new fragmentb();           ft.replace(r.id.frame_content, fragmentb);           ft.addtobackstack(null);            ft.commit();      }       @override        public view oncreateview(layoutinflater inflater, viewgroup container,     bundle savedinstancestate) {            view view = null;              view = inflater.inflate(r.layout.fragment_a, container, false);             nextt = (button) view.findviewbyid(r.id.button1);              nextt.setonclicklistener(this);              number = (edittext) view.findviewbyid(r.id.swtypee);             alpha = (edittext) view.findviewbyid(r.id.nume);          }    }    } 

//put value

yournewfragment ldf = new yournewfragment (); bundle args = new bundle(); args.putstring("yourkey", "yourvalue"); ldf.setarguments(args); 

//inflate fragment

getfragmentmanager().begintransaction().add(r.id.container, ldf).commit(); 

in oncreateview of new fragment:

//retrieve value

string value = getarguments().getstring("yourkey"); 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -