1
我停留在這一點上,我想在谷歌顯示工具欄下面兩個選項卡爲Play應用Xamarin的Android:不能使用ActionBar.Tab
下面是我在Xamarin用C#編寫,並使用解析代碼.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);
}
}
}
問題是:
1)的應用程序拋出異常上啓動此活性,但它編譯和安裝我的機器人裝置(API 22,機器人LOLLIPOP)上。
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>
這是我的屏幕布局
C#代碼應該是一樣的嗎? @BhavinKevadiya –
從哪裏可以下載Xamarin.v4.View.PagerTabStrip的支持庫。我嘗試通過組件添加,但它給我錯誤的解壓縮失敗@BhavinKevadiya –
我使用C#和Xamarin –