android - Populating Fragment with data instead of standing blank -


i have activity fetches serializable object database in activity. object contains function getname() returns string.

i want set string text of edit text contained in fragment. whatever do, it's not working. help?

form.java activity - hosts fragment, function tries edit fragment using "patient" object. sure object has been recieved activity, since shows in logcat.

public void populate(patient patient) {         frag1 fragment =                    (frag1) getsupportfragmentmanager().findfragmentbytag(                                "android:switcher:"+r.id.pager+":0");               if(fragment != null)               {                  if(fragment.getview() != null)                   {                     fragment.setname(patient.getname());                     fragment.getview().invalidate();                     log.d(patient.getname(), "supbrah"); // doesn't return :(                  }               }     } 

frag1.java - fragment's code

public class frag1 extends fragment {      edittext name;      @override     public view oncreateview(layoutinflater inflater, viewgroup container,              bundle savedinstancestate) {         view v = inflater.inflate(r.layout.activity_form, container, false);          name = (edittext) v.findviewbyid(r.id.name_edit);          return v;     }      public string getname() {         string patient = name.gettext().tostring();         return patient;     }      public void setname(string text) {         name.settext(text);     }  } 

thanks in advance!


Comments