Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin Android:无法使用ActionBar.Tab_Android_Xamarin_Xamarin.android_Android Tabs - Fatal编程技术网

Xamarin Android:无法使用ActionBar.Tab

Xamarin Android:无法使用ActionBar.Tab,android,xamarin,xamarin.android,android-tabs,Android,Xamarin,Xamarin.android,Android Tabs,我被困在这一点上,我想在工具栏下面显示两个选项卡,就像在谷歌Play应用程序中一样 下面是我在Xamarin中使用的代码,用C#编写,使用Parse.com后端 [Activity (Label = "Home")] public class Home : Activity { ImageView phone; Toolbar toolbar; protected override void OnCreate (Bundle bundle)

我被困在这一点上,我想在工具栏下面显示两个选项卡,就像在谷歌Play应用程序中一样

下面是我在Xamarin中使用的代码,用C#编写,使用Parse.com后端

    [Activity (Label = "Home")]         
public class Home : Activity
{
    ImageView phone;
    Toolbar toolbar;
    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);
        ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
        SetContentView (Resource.Layout.Home);

        toolbar = FindViewById<Toolbar> (Resource.Id.toolbar1);
        SetActionBar(toolbar);
        phone = FindViewById<ImageView> (Resource.Id.phonebutton);
        ActionBar.Title= "Welcome "+ ParseUser.CurrentUser.Get<String>("Name");
        ActionBar.Show ();

        ActionBar.Tab tab = ActionBar.NewTab ();
        tab.SetText ("Tab 1");
        tab.TabSelected += (sender, e) => {Toast.MakeText(this,"Tab1 selected",ToastLength.Long).Show();};
        ActionBar.AddTab (tab);

        ActionBar.Tab tab2 = ActionBar.NewTab ();
        tab.SetText ("Tab 2");
        tab.TabSelected += (sender, e) => {Toast.MakeText(this,"Tab2 selected",ToastLength.Long).Show();};
        ActionBar.AddTab (tab);
        //Responding phonebutton click
        phone.Click += Phone_Click;


    }

    void Phone_Click (object sender, EventArgs e)
    {
        var num = Android.Net.Uri.Parse ("tel:1234567891");
        Intent call = new Intent (Intent.ActionDial,num);
        StartActivity (call);
    }
}
[活动(Label=“Home”)]
公共班级之家:活动
{
图像查看电话;
工具栏;
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
ActionBar.NavigationMode=ActionBarNavigationMode.Tabs;
SetContentView(Resource.Layout.Home);
toolbar=findviewbyd(Resource.Id.toolbar1);
设置操作栏(工具栏);
phone=findviewbyd(Resource.Id.phonebutton);
ActionBar.Title=“Welcome”+ParseUser.CurrentUser.Get(“Name”);
Show();
Tab=ActionBar.NewTab();
tab.SetText(“表1”);
tab.TabSelected+=(sender,e)=>{Toast.MakeText(这是“Tab1 selected”,ToastLength.Long)。Show();};
ActionBar.AddTab(tab);
tab2=ActionBar.NewTab();
tab.SetText(“表2”);
tab.TabSelected+=(sender,e)=>{Toast.MakeText(这是“Tab2 selected”,ToastLength.Long)。Show();};
ActionBar.AddTab(tab);
//回应电话按钮点击
电话。点击+=电话\点击;
}
无效电话\单击(对象发送者,事件参数e)
{
var num=Android.Net.Uri.Parse(“电话:1234567891”);
意向调用=新意向(Intent.ActionDial,num);
星触觉(call);
}
}
}

问题是:
1) 该应用程序在启动此活动时引发异常,但它编译并安装在我的android设备上(API 22,android棒棒糖)。
2) 编译后,它给了我一个警告,说“ActionBar.NavigationMode过时了”,我不知道这是什么意思

请帮忙,谢谢

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res  /android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#cfd8dc"
android:minWidth="25px"
android:minHeight="25px">
<Toolbar
    android:minHeight="50dp"
    android:background="#90a4ae"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/toolbar1"
    android:theme="@style/StatusBarThemed" />
<ImageView
    android:src="@drawable/phone"
    android:layout_width="93.3dp"
    android:layout_height="52.2dp"
    android:id="@+id/phonebutton"
    android:clickable="true"
    android:scaleType="center"
    android:layout_alignParentRight="true" />
    </RelativeLayout>


这是我的屏幕布局

使用ViewPager和PagerTaskStrip for xml

请遵循以下示例的链接:-



将ViewPager和PagerTaskStrip用于xml

请遵循以下示例的链接:-



我可以从哪里下载Xamarin上.v4.View.PagerTabStrip的支持库。我尝试通过组件添加,但它给我错误的解压@BhavinKevadiyaI使用C#和Xamarin。我创建的选项卡没有占用他们可用的全部宽度。如何拉伸它们以使其两侧不留空白?我可以从何处下载Xamarin上的.v4.View.PagerTabStrip的支持库。我尝试通过组件添加,但这会导致解压@BhavinKevadiyaI失败的错误。我正在使用C#和Xamarin。我创建的选项卡没有占用它们可用的全部宽度。如何拉伸它们以使其两侧不留空白?我可以从何处下载Xamarin上的.v4.View.PagerTabStrip的支持库。我尝试通过组件添加,但这会导致解压@BhavinKevadiyaI失败的错误。我正在使用C#和Xamarin。我创建的选项卡没有占用它们可用的全部宽度。我如何拉伸它们,使其两侧不留空隙?
<android.support.v4.view.PagerTabStrip
    android:id="@+id/english_pager_header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:paddingBottom="4dp"
    android:paddingTop="4dp"
    android:textColor="#bb343c" />