android - Fragment inside fragment not working -
i have made fragment inside fragment , when click on list item in list , works because toast method shows message new fragment not adding... shows remains same....
   @override         public void onitemclick(adapterview<?> parent, view view, int position, long id) {             textview t_profile_name = (textview) view.findviewbyid(r.id.profile_name);              textview t_profile_hometown = (textview) view.findviewbyid(r.id.profile_hometown);               string user_name = t_profile_name.gettext().tostring();              string  user_hometown = t_profile_hometown.gettext().tostring();              string getid = user_id[position];              sharedpreferences sharedpreferences = getactivity().getsharedpreferences("comm_data", getcontext().mode_private);             string getid = sharedpreferences.getstring("user_id", "");              toast.maketext(getcontext(), user_name+" "+user_hometown+" "+getid+""+getid, toast.length_short).show();                //msocket.emit("message", "getuser");             fragmentmanager fragmentmanager = getchildfragmentmanager();             fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction();             fragmenttransaction.add(new chat_box(),"chat_box");             fragmenttransaction.addtobackstack("chat");             fragmenttransaction.commit(); 
you should tell fragment manager add fragment somewhere. @mike said, use fragmenttransaction#add(int,fragment, string). code should fragmenttransaction.add(r.id.the_container,new chat_box(),"chat_box");
Comments
Post a Comment