FragmentTabHost in VS2013 - xamarin C#
-
first of all thanks for ur attention. i have it in "activity_main.axml" :
And the mTabHost isnot nulll in
mTabHost = FindViewById(Resource.Id.tabhostN );
Or Possible to give me and C# xamarin example for doing the same i have done? any further question?
Did you actually check the value of this variable at run time? It matters not what you write in your source code, the only way to be sure it works is to check it at the time of error. If it is not that variable that causes the error then it must be one of the others. I also notice that you have this code within a
try/catch
block, but you eat the exception. This is really bad practice and leads to situations just such as this. Exceptions provide useful information, so make proper use of them. -
Did you actually check the value of this variable at run time? It matters not what you write in your source code, the only way to be sure it works is to check it at the time of error. If it is not that variable that causes the error then it must be one of the others. I also notice that you have this code within a
try/catch
block, but you eat the exception. This is really bad practice and leads to situations just such as this. Exceptions provide useful information, so make proper use of them. -
i have used this for sample for that the catch is not complete. at runtime the mtabHost is not null. i have breakepoint in
mTabHost.AddTab(spec);
and the error occured in here. thanks in advanced!
-
Then you need to establish what value is causing the exception. We cannot guess it from the information you have provided.
-
Sorry, I don't use Xamarin, and that is not really the solution; if you find another sample and that one does not work, what then? If you aspire to be a developer then you really need to practice diagnosing problems, even if you need help solving them.
-
Sorry, I don't use Xamarin, and that is not really the solution; if you find another sample and that one does not work, what then? If you aspire to be a developer then you really need to practice diagnosing problems, even if you need help solving them.
-
I have tried to explain how: you use your debugger to step through the code and look to see what variable is not being set up correctly. You can only solve it by collecting all the information around the time of error.
-
Thanks i have done that! I should change :
mTabHost.AddTab(spec);
To :
mTabHost.Setup(this, SupportFragmentManager, Resource.Id.tabFrameLayout);
mTabHost.AddTab(spec, Java.Lang.Class.FromType(typeof(Fragment1)), null);end of story That is all!