java - Create RecyclerView List From Edit Text Content -


enter image description here have recyclerview in fragment , want when user press button below "add new row" redirect new fragment till here there no problem can achieve want details filled in form show new row in recyclerview

as can see in image above user can add row in recyclerview dynamically , there cross top right of every row delete row list.

so,what want is

1) how can add row list form inputs user press save event show user newly added row entered details in form

in short want add row dynamically list user inputs in form , delete list when user press cross button @ top right of row item

i solved issue myself did data first fragment second fragment first create interface send result fragment_1(which has recyclerview) fragment_2(which has form)

here form code

    @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view view=inflater.inflate(r.layout.ppl_details_form,container,false);         ppl_title_spinner= (spinner) view.findviewbyid(r.id.ppl_spinner);         title= (edittext) view.findviewbyid(r.id.ppl_title);         address= (autocompletetextview) view.findviewbyid(r.id.ppl_address);         year= (edittext) view.findviewbyid(r.id.ppl_passing_year);         description= (edittext) view.findviewbyid(r.id.ppl_description);         btn1= (button) view.findviewbyid(r.id.ppl_map_button);          save= (button) view.findviewbyid(r.id.ppl_save);         save_ppl.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 title=title.gettext().tostring();                 address= address.gettext().tostring();                 year=year.gettext().tostring();                 description=description.gettext().tostring();                 //ppl wrapper                 ppl_list_wrapper list=new ppl_list_wrapper(title,year,address);                  add_ppl=(ppl_transfer_data_to_list)getactivity();                 add_ppl.addlocation(list);                 fragment_1 fragment1=new fragment_1();                 fragmenttransaction fragmenttransaction=getfragmentmanager().begintransaction();                 fragmenttransaction.replace(r.id.navigation_main_layout,fragment1);                 fragmenttransaction.commit();              }         });       @override     public void onattach(context context) {         super.onattach(context);         try{             add_ppl= (ppl_transfer_data_to_list) context;         }         catch (classcastexception e){             throw new classcastexception(getactivity().tostring()+" must implement interface");         }     } 

and implement infterface parent activity , call fragment_1 method activity this

 @override     public void addevent(ppl_list_wrapper ppl_data) {         fragment_1 recycler=new fragment_1();         recycler.ppl_eve(ppl_data);      } 

then data fragment_1 , have make arraylist in fragment static cause without static list lost reference , data , stop showing data recyclerview

 public void ppl_eve(final ppl_list_wrapper ppl_list_wrapper){         ppl_wrapper=ppl_list_wrapper;            event_details.add(ppl_list_wrapper);//static arraylist         adapter=new ppl_recycler_adapter(getactivity(),event_details);         adapter.notifydatasetchanged();      } 

i have make sure list static

static list<ppl_list_wrapper> event_details=new arraylist<ppl_list_wrapper>(); 

Comments