我在尝试设置导航模式时如何解决它
[Activity(Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity,ActionBar.ITabListener {
private ActionBar ab;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
try{
//here i am getting instance of action bar
ab = ActionBar;
**i am getting error at this line **
ab.NavigationMode = ActionBarNavigationMode.Tabs;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
}
}
答案 0 :(得分:2)
我运行了你的代码,唯一的例外是我没有暗示ITabListener,而且它有效。
[Activity (Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity
{
private ActionBar ab;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
try {
//here i am getting instance of action bar
ab = ActionBar;
**i am getting error at this line **
ab.NavigationMode = ActionBarNavigationMode.Tabs;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
} catch (Exception ex) {
throw ex;
}
}
}
我从来没有见过有人使用动作栏来暗示ITabListener(在xamarin上)。我会采取xamarin的方式来建立一个动作栏。 Here是文档的链接。