android - How to send data From activity to Fragment Activity? -


i have referred many code on question , can not problem. code want send data previous fragmentactivity:

public class addtask extends activity {  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.add_task);      imagebutton position = (imagebutton) findviewbyid(r.id.select_position);      position.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {              intent m = new intent().setclass(getapplicationcontext(),                     mapactivity.class);             startactivity(m);          }     });  }  @override public boolean oncreateoptionsmenu(menu menu) {      getmenuinflater().inflate(r.menu.menu_add_task, menu);     return super.oncreateoptionsmenu(menu); }  @override public boolean onoptionsitemselected(menuitem item) {     switch (item.getitemid()) {     case r.id.accept:         finishactivity();         finish();         break;     case r.id.cancle:         finish();         break;     }     return super.onoptionsitemselected(item); }  protected void finishactivity() {     edittext activity = (edittext) findviewbyid(r.id.activity_name);     edittext description = (edittext) findviewbyid(r.id.description);     edittext address = (edittext) findviewbyid(r.id.address);      bundle bundle = new bundle();     bundle.putstring("activity", activity.gettext().tostring());     if (activity.tostring().isempty() || description.tostring().isempty()             || address.tostring().isempty()) {          toast.maketext(this, "field must not empty", toast.length_long)                 .show();     } } } 

can tell me use in code send data, have used fragment class send make error in activity.

bundle bundle = new bundle(); bundle.putstring("edttext", "from activity"); // set fragmentclass arguments fragmentclass fragobj = new fragmentclass(); fragobj.setarguments(bundle); 
and in fragment oncreateview method:     @override     public view oncreateview(layoutinflater inflater, viewgroup container,             bundle savedinstancestate) {         string strtext = getarguments().getstring("edttext");             return inflater.inflate(r.layout.fragment, container, false);     } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -