I am stuck at this point where I want to display two tabs below toolbar as in Google Play app
Below is the code I used in Xamarin written in C# and using Parse.com backend.
[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);
}
}
}
Problem is:
1) The app throws an exception on launching this activity but it compiles and installs on my android device (API 22,Android LOLLIPOP).
2) After compiling it gives me a warning saying "ActionBar.NavigationMode is obsolete" and I don't know what that means.!
Please help,Thanks
<?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>
This is my layout for screen
use ViewPager and PagerTabStrip for xml
follow the link fro Example :- http://www.androidbegin.com/tutorial/android-viewpagertabstrip-fragments-tutorial/