mono - Passing Data between Activities of TabHost Control -
i have tabhost add tab's dynamically. problem updating data in 1 tab tab values selected.
for ex: have 2 tabs named 'search & filter' , intents added in tabhost activity page. when select values spinners 'site & equipment' filter tab want update search tab list view specified selection filter tab.
i have attached sample code. kindly verify , suggest me on same.
tabhost activity:
public class tabsearch : tabactivity { protected override void oncreate(bundle bundle) { base.oncreate(bundle); setcontentview(resource.layout.search_wotab); tabhost.tabspec tspec; intent intent; intent = new intent(this, typeof(wosearch)); intent.addflags(activityflags.newtask); tspec = tabhost.newtabspec("search"); tspec.setindicator("search", resources.getdrawable(resource.drawable.search)); tspec.setcontent(intent); tabhost.addtab(tspec); intent = new intent(this, typeof(wofilter)); intent.addflags(activityflags.newtask); tspec = tabhost.newtabspec("filter"); tspec.setindicator("filter", resources.getdrawable(resource.drawable.filter)); tspec.setcontent(intent); tabhost.addtab(tspec); tabhost.tabchanged += (sender, e) => { spinner workorder = findviewbyid<spinner>(resource.id.sp_site); object data; //here showing null spinner control if (workorder!=null) data = workorder.selecteditem; toast.maketext(this, tabhost.currenttab.tostring(), toastlength.short).show(); }; } }
what :
in wofilter tab :
- when select element update app_wide var (static, sharedpref, database, like) let's "wo_filter_value". way, wofilter activity don't have know wosearch activity
in wosearch tab :
- only initialisation code in "oncreate" method (what's need 1 once)
- do list display part in "onresume" method, reading updated "wo_filter_value" , filtering accordingly.
as 1 tab displayed @ same time, activity have go through "onresume" function before redisplaying list after have changed filter on other tab.
Comments
Post a Comment