android fragments - How to build your own tabs in MvvmCross? -


i'm trying build own tabs in monodroid , mvvmcross.

the reason building own tabs can have further control on them. want them on every screen if aren't in tabs, want control clicks on tabs.

loading 2 fragments on page fine, when click button on either tab fragment or content fragment navigates next content fragment getting error message "an unhandled exception occured." isn't helpful.

 02-06 10:15:13.947 w/dalvikvm( 2040): jni warning: jni method called exception pending  02-06 10:15:13.947 w/dalvikvm( 2040):              in lcirrious/mvvmcross/droid/fragging/mvxeventsourcefragmentactivity;.n_startactivityforresult:(landroid/content/intent;i)v (newstring)  in mgmain jni_onload  02-06 10:15:13.947 w/dalvikvm( 2040): pending exception is:  02-06 10:15:13.947 i/dalvikvm( 2040): android.content.activitynotfoundexception: unable find explicit activity class {frags.droid/frags.droid.views.frags.childtwoview}; have declared activity in androidmanifest.xml?  02-06 10:15:13.947 i/dalvikvm( 2040):   (raw stack trace not found)  02-06 10:15:13.947 i/dalvikvm( 2040): "main" prio=5 tid=1 native  02-06 10:15:13.947 i/dalvikvm( 2040):   | group="main" scount=0 dscount=0 obj=0x41aaf710 self=0x41a96210  02-06 10:15:13.957 i/dalvikvm( 2040):   | systid=2040 nice=0 sched=0/0 cgrp=apps handle=1074675708  02-06 10:15:13.957 i/dalvikvm( 2040):   | state=r schedstat=( 0 0 0 ) utm=164 stm=41 core=0  02-06 10:15:13.967 i/dalvikvm( 2040):   #00  pc 000012fe  /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)  02-06 10:15:13.967 i/dalvikvm( 2040):   #01  pc 0006324e  /system/lib/libdvm.so (dvmdumpnativestack(debugoutputtarget const*, int)+33)  02-06 10:15:13.967 i/dalvikvm( 2040):   #02  pc 000572b8  /system/lib/libdvm.so (dvmdumpthreadex(debugoutputtarget const*, thread*, bool)+395)  02-06 10:15:13.967 i/dalvikvm( 2040):   #03  pc 00057326  /system/lib/libdvm.so (dvmdumpthread(thread*, bool)+25)  02-06 10:15:13.967 i/dalvikvm( 2040):   #04  pc 0003b530  /system/lib/libdvm.so  02-06 10:15:13.967 i/dalvikvm( 2040):   #05  pc 0003eef2  /system/lib/libdvm.so  02-06 10:15:13.967 i/dalvikvm( 2040):   @ cirrious.mvvmcross.droid.fragging.mvxeventsourcefragmentactivity.n_startactivityforresult(native method)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ cirrious.mvvmcross.droid.fragging.mvxeventsourcefragmentactivity.startactivityforresult(mvxeventsourcefragmentactivity.java:110)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.app.activity.startactivity(activity.java:3661)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.app.activity.startactivity(activity.java:3629)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ mono.android.view.view_onclicklistenerimplementor.n_onclick(native method)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ mono.android.view.view_onclicklistenerimplementor.onclick(view_onclicklistenerimplementor.java:29)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.view.view.performclick(view.java:4475)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.view.view$performclick.run(view.java:18786)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.os.handler.handlecallback(handler.java:730)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.os.handler.dispatchmessage(handler.java:92)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.os.looper.loop(looper.java:137)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ android.app.activitythread.main(activitythread.java:5419)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ java.lang.reflect.method.invokenative(native method)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ java.lang.reflect.method.invoke(method.java:525)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1187)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1003)  02-06 10:15:13.967 i/dalvikvm( 2040):   @ dalvik.system.nativestart.main(native method) 

all custom code below.

i have own custompresenter

public class custompresenter : mvxandroidviewpresenter, icustompresenter {     // map between view-model , fragment host creates , shows view based on view-model type     private dictionary<type, ifragmenthost> dictionary = new dictionary<type, ifragmenthost>();      public override void show(mvxviewmodelrequest request)     {         ifragmenthost host;         if (this.dictionary.trygetvalue(request.viewmodeltype, out host))         {             if (host.show(request))             {                 return;             }         }         base.show(request);     }      public void register(type viewmodeltype, ifragmenthost host)     {         this.dictionary[viewmodeltype] = host;     } } 

i'm using mvxfragmentactivity host view contain content section @ top , tabs @ bottom, implements ifragmenthost. pages fragments including tabs.

public class firstview : mvxfragmentactivity, ifragmenthost {      childtwoview _childtwo;      public bool show(cirrious.mvvmcross.viewmodels.mvxviewmodelrequest request)     {         // create view model         var loaderservice = mvx.resolve<imvxviewmodelloader>();         var viewmodel = loaderservice.loadviewmodel(request, null /* saved state */);          _childtwo = (childtwoview)supportfragmentmanager.findfragmentbyid(resource.layout.childtwoview);          var custompresenter = mvx.resolve<icustompresenter>();         //custompresenter.register(type)          // decide fragment create based on view-model type          var fm = this.supportfragmentmanager;         var ft = fm.begintransaction();           if (viewmodel.gettype().name == "childtwoviewmodel")         {             var fragmentview = new childtwoview();             ft.replace(resource.id.childviewhost, fragmentview);         }          //var fragmentview = viewmodel.gettype().name;         // load fragment view           ft.addtobackstack(null);         ft.commit();         return true;     }      protected override void oncreate(bundle bundle)     {         base.oncreate(bundle);         setcontentview(resource.layout.firstview);          var childview = new childview()         {             viewmodel = new childviewmodel()         };          var tabview = new tabview()         {             viewmodel = new tabviewmodel()         };         var fm = this.supportfragmentmanager;         var ft = fm.begintransaction();         //ft.add(childview, "child");          ft.replace(resource.id.childviewhost, childview, "child");           ft.replace(resource.id.tabviewhost, tabview, "tab");         ft.commit();     }  } 

i setting these in setup.cs

protected override imvxandroidviewpresenter createviewpresenter() {     var custompresenter = new custompresenter();     mvx.registersingleton<icustompresenter>(custompresenter);     return custompresenter; } 

all appreciated.

edit

i decided against approach , went standard android tabhost keep consistency between apps.

the error says all. have forgot add activity attribute childtwoview like:

[activity] public class childtwoview : activity { ... } 

oh wait, childtwoview not activity, when can't use built in show method in presenter. not support fragments.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -