public TabLayoutOnTabSelectedListener(Context context, ViewPager viewPager, ActionBar actionBar, TabLayout tabLayout) { this.context = context; this.viewPager = viewPager; this.actionBar = actionBar; this.tabLayout = tabLayout; }
private void TabLayoutViewPager() { tabLayout = FindViewById <TabLayout>(Resource.Id.tab_layout); tabLayout.TabGravity = TabLayout.GravityFill; tabLayout.TabMode = TabLayout.ModeScrollable; // PagerAdapter.FragmentPosition과 순서를 맞출것 tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.work_path_fragment))); tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_count_fragment))); tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_condition_fragment))); tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.backup_path_fragment))); viewPager = FindViewById <ViewPager>(Resource.Id.pager); pagerAdapter = new PagerAdapter(SupportFragmentManager, tabLayout.TabCount); viewPager.Adapter = pagerAdapter; viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); tabLayout.SetOnTabSelectedListener(new TabLayoutOnTabSelectedListener(this, viewPager, actionBar, tabLayout)); }
private void TabLayoutViewPager() { tabLayout = FindViewById<TabLayout>(Resource.Id.tab_layout); tabLayout.TabGravity = TabLayout.GravityFill; tabLayout.TabMode = TabLayout.ModeScrollable; // PagerAdapter.FragmentPosition과 순서를 맞출것 tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.work_path_fragment))); tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_count_fragment))); tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.weld_condition_fragment))); tabLayout.AddTab(tabLayout.NewTab().SetText(Resources.GetString(Resource.String.backup_path_fragment))); viewPager = FindViewById<ViewPager>(Resource.Id.pager); pagerAdapter = new PagerAdapter(SupportFragmentManager, tabLayout.TabCount); viewPager.Adapter = pagerAdapter; viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); tabLayout.SetOnTabSelectedListener(new TabLayoutOnTabSelectedListener(this, viewPager, actionBar, tabLayout)); }
public void OnTabUnselected(TabLayout.Tab tab) { }
public void OnTabSelected(TabLayout.Tab tab) { viewPager.SetCurrentItem(tab.Position, true); switch ((PagerAdapter.FragmentPosition)tab.Position) { case PagerAdapter.FragmentPosition.WorkPathFragment: SetBackground(Resource.Color.tab1_actionbar_background, Resource.Color.tab1_tablayout_background, Resource.Color.tab1_tabindicator_background); break; case PagerAdapter.FragmentPosition.WeldCountFragment: SetBackground(Resource.Color.tab2_actionbar_background, Resource.Color.tab2_tablayout_background, Resource.Color.tab2_tabindicator_background); break; case PagerAdapter.FragmentPosition.WeldConditionFragment: SetBackground(Resource.Color.tab3_actionbar_background, Resource.Color.tab3_tablayout_background, Resource.Color.tab3_tabindicator_background); break; case PagerAdapter.FragmentPosition.BackupPathFragment: SetBackground(Resource.Color.tab4_actionbar_background, Resource.Color.tab4_tablayout_background, Resource.Color.tab4_tabindicator_background); break; } var ir = (IRefresh)((PagerAdapter)viewPager.Adapter)[tab.Position]; if (ir != null) ir.Refresh(); }
public TabLayoutOnTabSelectedListener(Context context, ViewPager viewPager, ActionBar actionBar, TabLayout tabLayout) { this.context = context; this.viewPager = viewPager; this.actionBar = actionBar; this.tabLayout = tabLayout; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Main_TxtView_Header = FindViewById <TextView>(Resource.Id.Main_TxtView_Header); Main_TxtView_Header.Click += delegate { }; Main_ImageView_Search = FindViewById <ImageView>(Resource.Id.Main_ImageView_Search); Main_TextView_Location = FindViewById <TextView>(Resource.Id.Main_TextView_Location); Main_Button_Home = FindViewById <Button>(Resource.Id.Main_Button_Home); Main_Button_Order = FindViewById <Button>(Resource.Id.Main_Button_Order); Main_Button_Order.Click += delegate { //پیام Intent oi = new Intent(this, typeof(Message_Activity)); StartActivity(oi); }; Main_ImageButton_Menu = FindViewById <ImageButton>(Resource.Id.Main_ImageButton_Menu); Main_Button_Basket = FindViewById <Button>(Resource.Id.Main_Button_Basket); Main_Button_Basket.Click += delegate { //سبد خرید Intent oi = new Intent(this, typeof(Basket_activity)); StartActivity(oi); }; Main_Button_Account = FindViewById <Button>(Resource.Id.Main_Button_Account); Main_Button_Account.Click += delegate { //حساب Intent oi = new Intent(this, typeof(Account_Activity)); StartActivity(oi); }; Main_ViewPager_SliderFood = FindViewById <ViewPager>(Resource.Id.Main_ViewPager_SliderFood); Main_TabLayouts_WithPager = FindViewById <Android.Support.Design.Widget.TabLayout>(Resource.Id.Main_TabLayouts_WithPager); Main_Button_Resturant = FindViewById <Button>(Resource.Id.Main_Button_Resturant); Main_Button_Resturant.Click += delegate { //رستوران //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //انتخاب رستوان Intent oi = new Intent(this, typeof(SelectResturant_Activity)); StartActivity(oi); // } }; Main_Button_FastFood = FindViewById <Button>(Resource.Id.Main_Button_FastFood); Main_Button_FastFood.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} // else // { //فست غود Intent oi = new Intent(this, typeof(SelectedFastFoood_Activity)); StartActivity(oi); // } }; Main_Button_Drink = FindViewById <Button>(Resource.Id.Main_Button_Drink); Main_Button_Drink.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //نوشیدنی Intent oi = new Intent(this, typeof(SelectDrink_Activity)); StartActivity(oi); // } }; Main_Button_Icecream = FindViewById <Button>(Resource.Id.Main_Button_Icecream); Main_Button_Icecream.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //بستنی Intent oi = new Intent(this, typeof(SelectedIceCreame_Activity)); StartActivity(oi); // } }; Main_Button_Liver = FindViewById <Button>(Resource.Id.Main_Button_Liver); Main_Button_Liver.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //چگرکی Intent oi = new Intent(this, typeof(SelectedLiver)); StartActivity(oi); // } }; Main_Button_Tabakhi = FindViewById <Button>(Resource.Id.Main_Button_Tabakhi); Main_Button_Tabakhi.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //طباخی Intent oi = new Intent(this, typeof(SelectedTabakhi_Activity)); StartActivity(oi); //} }; Main_Button_Connfectionary = FindViewById <Button>(Resource.Id.Main_Button_Connfectionary); Main_Button_Connfectionary.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //قنادی Intent oi = new Intent(this, typeof(SelectedTwoConf)); StartActivity(oi); // } }; Main_Button_Alas = FindViewById <Button>(Resource.Id.Main_Button_Alas); Main_Button_Alas.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //اش Intent oi = new Intent(this, typeof(SelectedAlas_Activity)); StartActivity(oi); // } }; Main_Button_Breads = FindViewById <Button>(Resource.Id.Main_Button_Breads); Main_Button_Breads.Click += delegate { //if (Main_TextView_Location.Text == "نام شهر,نام منطقه") //{ // Snackbar snackBar = Snackbar.Make(Main_Button_Order, "لطفا ابتدا موقعیت مکانی را مشخص فرمایید", Snackbar.LengthIndefinite).SetAction("تایید", (v) => // { // Finish(); // }); // snackBar.SetActionTextColor(Android.Graphics.Color.Green); // snackBar.Show(); //} //else //{ //نون Intent oi = new Intent(this, typeof(SelectedBread_Activity)); StartActivity(oi); // } }; //string[] ITEMS = { "شیراز,معالی آباد", "شیراز,چهارراه زند", "شیراز,چمران" }; //var adapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleSpinnerItem, ITEMS); //adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); //Main_Spinner_Location.Hint = "نام شهر-اسم منطقه "; //Main_Spinner_Location.TextDirection = TextDirection.FirstStrongLtr; //Main_Spinner_Location.Adapter = adapter; //string[] ITEMS = { "شیراز,معالی آباد", "شیراز,چهارراه زند", "شیراز,چمران" }; var items = new List <string>() { "نام شهر,نام منطقه", "شیراز,معالی آباد", "اهواز,نادری" }; // var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, items); // Main_Spinner_Location Main_TextView_Location.Click += delegate { Intent oi = new Intent(this, typeof(LocationActivity)); StartActivity(oi); }; // Main_Spinner_Location.Adapter = adapter; Main_ViewPager_SliderFood.Adapter = new imageAdapter(this); var timer = new System.Timers.Timer(); timer.Interval = 3000; timer.Enabled = true; int page = 0; timer.Elapsed += (sender, args) => { RunOnUiThread(() => { if (page <= Main_ViewPager_SliderFood.Adapter.Count) { page++; } else { page = 0; } Main_ViewPager_SliderFood.SetCurrentItem(page, true); }); }; var dots = FindViewById <TabLayout>(Resource.Id.Main_TabLayouts_WithPager); // dots.SetupWithViewPager(Main_ViewPager_SliderFood, true); // Main_TabLayouts_WithPager.SetupWithViewPager(Main_ViewPager_SliderFood, true); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.RestaurantProfileLayout); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); Android.Support.V7.Widget.Toolbar toolbarNav = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbarNav); ImageView imageView = FindViewById <ImageView>(Resource.Id.imageView); TextView textview1 = FindViewById <TextView>(Resource.Id.textView1); TextView textview2 = FindViewById <TextView>(Resource.Id.textView2); TextView textview3 = FindViewById <TextView>(Resource.Id.textView3); ratingBar = FindViewById <RatingBar>(Resource.Id.ratingBar1); tabLayout = FindViewById <Android.Support.Design.Widget.TabLayout>(Resource.Id.tabLayout); saveButton = FindViewById <ImageButton>(Resource.Id.imageButton1); viewPager = FindViewById <ViewPager>(Resource.Id.viewPager); var restaurantInfo = JsonConvert.DeserializeObject <Post>(Intent.GetStringExtra("RestaurantInfo")); var imageBitmap = ImageHelper.GetImageBitmapFromUrl(restaurantInfo.MainPhoto1); imageView.SetImageBitmap(imageBitmap); textview1.Text = restaurantInfo.RestaurantName; if (restaurantInfo.Cost == "1") { textview2.Text = "£"; } else if (restaurantInfo.Cost == "2") { textview2.Text = "££"; } else if (restaurantInfo.Cost == "3") { textview2.Text = "£££"; } if (restaurantInfo.Cuisines == null && restaurantInfo.Categories == null) { textview3.Text = ""; } else if (restaurantInfo.Cuisines != null && restaurantInfo.Categories == null) { textview3.Text = restaurantInfo.Cuisines; } else if (restaurantInfo.Cuisines == null && restaurantInfo.Categories != null) { textview3.Text = restaurantInfo.Categories; } else if (restaurantInfo.Cuisines != null && restaurantInfo.Categories != null) { textview3.Text = restaurantInfo.Cuisines + " " + restaurantInfo.Categories; } ID = restaurantInfo.ID; saveButton.Click += saveButtonClick; ratingBar.RatingBarChange += ratingClick; SetSupportActionBar(toolbarNav); SetupViewPager(viewPager); tabLayout.SetupWithViewPager(viewPager); viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); checkIfUserHasSavedRestaurant(ID); }