我现在陷入困境,我想在Google Play应用
中显示工具栏下方的两个标签以下是我用X#编写并使用Parse.com后端编写的Xamarin代码。
[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)应用程序在启动此活动时抛出异常,但它在我的Android设备(API 22,Android LOLLIPOP)上编译和安装。
2)编译之后,它给了我一个警告说&#34; ActionBar.NavigationMode已经过时&#34;我不知道这意味着什么。!
请帮忙,谢谢
<?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>
这是我的屏幕布局
答案 0 :(得分:0)
使用ViewPager和PagerTabStrip for xml
点击示例中的链接: - http://www.androidbegin.com/tutorial/android-viewpagertabstrip-fragments-tutorial/
<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" />