fragment tab host - Android - How to reload a content of a FragmentTabHost -


so have class extends fragment, in it, have fragmenttabhost, fragmenttabhost consist of 3 tab, each tab show list of item.. inside each item can update item property name/ other property. problem after update value , pressed button, list of item still consist old list item value isn't updated. list updated if switch tab , go again. i've been struggling couple of hours problem, appreciated thanks

package com.example.hansel.tapbandung_v00.page.menu_parent;   import android.content.context; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmenttabhost; import android.support.v4.app.fragmenttransaction; import android.util.log; import android.view.layoutinflater; import android.view.menuitem; import android.view.view; import android.view.viewgroup;  import com.example.hansel.tapbandung_v00.r; import com.example.hansel.tapbandung_v00.page.submenu_bus.bus_category; import com.example.hansel.tapbandung_v00.page.submenu_bus.bus_featured; import com.example.hansel.tapbandung_v00.page.submenu_bus.bus_newest;  /**  * created hansel on 5/25/2015.  */ public class business_parent extends fragment{ private fragmenttabhost mtabhost; context context;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     context = getactivity().getapplicationcontext(); }  @override public view oncreateview(layoutinflater inflater, viewgroup parent, bundle savedinstancestate) {      //3 tab category, dll     mtabhost = new fragmenttabhost(getactivity());     mtabhost.setup(getactivity(), getchildfragmentmanager(), r.id.tabhost);     mtabhost.addtab(mtabhost.newtabspec("featured").setindicator("featured"),             bus_featured.class, null);     mtabhost.addtab(mtabhost.newtabspec("category").setindicator("category"),             bus_category.class, null);     mtabhost.addtab(mtabhost.newtabspec("newest").setindicator("newest"),             bus_newest.class, null);     return mtabhost; }  @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();      //noinspection simplifiableifstatement     if (id == r.id.action_settings) {         return true;     }     return super.onoptionsitemselected(item); }  @override public void ondestroyview() {     super.ondestroyview();     mtabhost = null; } 

}

i've been struggling same problem, , came such solution:

mtabhost.gettabwidget().getchildat(0).setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             getsupportfragmentmanager().begintransaction().replace(android.r.id.tabcontent, new tab1fragment()).commit();             mtabhost.setcurrenttab(0);         }     });      mtabhost.gettabwidget().getchildat(1).setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             getsupportfragmentmanager().begintransaction().replace(android.r.id.tabcontent, new tab2fragment()).commit();             mtabhost.setcurrenttab(1);         }     });      mtabhost.gettabwidget().getchildat(2).setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             getsupportfragmentmanager().begintransaction().replace(android.r.id.tabcontent, new tab3fragment()).commit();             mtabhost.setcurrenttab(2);         }     }); 

it works. i'm not sure elegant solution though.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -