c# - An unhandled exception occured in TabView in Xamarin Android in VS2012 -


    **an unhandled exception occurred in tab view in xamarin android in vs2012**      **this layout main.axml** 

i have no knowledge tab view implement in xamarin using c# , use vs2012 please me error occurred when run application in android emulator in visual studio alert box unhandled exception

    <?xml version="1.0" encoding="utf-8"?>     <tabhost xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@android:id/tabhost"         android:layout_width="fill_parent"         android:layout_height="fill_parent">         <linearlayout             android:orientation="vertical"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:padding="5dp">             <tabwidget                 android:id="@android:id/tabs"                 android:layout_width="fill_parent"                 android:layout_height="wrap_content" />             <framelayout                 android:id="@android:id/tabcontent"                 android:layout_width="fill_parent"                 android:layout_height="fill_parent"                 android:padding="5dp" />         </linearlayout>     </tabhost> 

this mainactiviy activity1.cs

    using system;      using android.app;     using android.content;     using android.runtime;     using android.views;     using android.widget;     using android.os;      namespace tabview      {         [activity(label = "tabview", mainlauncher = true, icon = "@drawable/icon")]         public class activity1 : tabactivity         {               protected override void oncreate(bundle bundle)             {                 base.oncreate(bundle);                  // set our view "main" layout resource                 setcontentview(resource.layout.main);                 createtab(typeof(whatsonactivity), "whats_on", "what's on", resource.drawable.ic_tab_whats_on);                 createtab(typeof(speakersactivity), "speakers", "speakers", resource.drawable.ic_tab_speakers);                 createtab(typeof(sessionsactivity), "sessions", "sessions", resource.drawable.ic_tab_sessions);                 createtab(typeof(myscheduleactivity), "my_schedule", "my schedule", resource.drawable.ic_tab_my_schedule);              }             private void createtab(type activitytype, string tag, string label, int drawableid)             {                 var intent = new intent(this, activitytype);                 intent.addflags(activityflags.newtask);                  var spec = tabhost.newtabspec(tag);                 var drawableicon = resources.getdrawable(drawableid);                 spec.setindicator(label, drawableicon);                 spec.setcontent(intent);                  tabhost.addtab(spec);             }               }         } 

i want 4 tab in application

    **this 1st tab activity myscheduleactivity.cs**      using system;     using system.collections.generic;     using system.linq;     using system.text;      using android.app;     using android.content;     using android.os;     using android.runtime;     using android.views;     using android.widget;      namespace tabview     {         [activity]         public class myscheduleactivity : activity         {             protected override void oncreate(bundle bundle)             {                 base.oncreate(bundle);                  textview textview = new textview(this);                 textview.text = "this schedule tab";                 setcontentview(textview);             }         }     }       **this 2nd activity sessionsactivity.cs**      using system;     using system.collections.generic;     using system.linq;     using system.text;      using android.app;     using android.content;     using android.os;     using android.runtime;     using android.views;     using android.widget;      namespace tabview     {         [activity]         public class sessionsactivity : activity         {             protected override void oncreate(bundle bundle)             {                 base.oncreate(bundle);                  textview textview = new textview(this);                 textview.text = "this session tab";                 setcontentview(textview);             }         }     }       **this 3rd activity speakersactivity.cs**      using system;     using system.collections.generic;     using system.linq;     using system.text;      using android.app;     using android.content;     using android.os;     using android.runtime;     using android.views;     using android.widget;      namespace tabview     {         [activity]         public class speakersactivity : activity         {             protected override void oncreate(bundle bundle)             {                 base.oncreate(bundle);                  textview textview = new textview(this);                 textview.text = "this speakers tab";                 setcontentview(textview);             }         }     }  **this 4th activity whatsonactivity.cs**  using system; using system.collections.generic; using system.linq; using system.text;  using android.app; using android.content; using android.os; using android.runtime; using android.views; using android.widget;  namespace tabview {     [activity]     public class whatsonactivity : activity     {         protected override void oncreate(bundle bundle)         {             base.oncreate(bundle);              textview textview = new textview(this);             textview.text = "this whats on tab";             setcontentview(textview);         }     } }   **and**  **this xml in  resources=>drawable folder**   1) ic_tab_my_schedule.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">   <item android:drawable="@drawable/ic_tab_my_schedule" android:state_selected="true"/>   <item android:drawable="@drawable/ic_tab_my_schedule"/> </selector>   2)ic_tab_sessions.xml <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android">   <item android:drawable="@drawable/ic_tab_sessions"         android:state_selected="true"/>   <item android:drawable="@drawable/ic_tab_sessions"/> </selector>  3)ic_tab_speakers.xml <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android">   <item android:drawable="@drawable/ic_tab_speakers"         android:state_selected="true"/>   <item android:drawable="@drawable/ic_tab_speakers"/> </selector>  4)ic_tab_whats_on.xml <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android">   <item android:drawable="@drawable/ic_tab_whats_on"         android:state_selected="true"/>   <item android:drawable="@drawable/ic_tab_whats_on"/> </selector> 

and added 2 images in drawable folder selected state , unselected state!

and follow link :-tabhost walkthrough

thakns in advance please hope response..

maybe should start working sample

https://github.com/xamarin/monodroid-samples/blob/master/apidemo/tutorials/tablayouttutorial.cs


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -