protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //Main TabHost tabHost = FindViewById <TabHost> (Resource.Id.tabHost); tabHost.Setup(this.LocalActivityManager); TabHost.TabSpec tabSpec1 = tabHost.NewTabSpec("Contacts"); TabHost.TabSpec tabSpec2 = tabHost.NewTabSpec("Settings"); Intent intent; tabSpec1.SetIndicator("Contacts"); intent = new Intent(this, typeof(ContactsActivity)); intent.AddFlags(ActivityFlags.NewTask); tabSpec1.SetContent(intent); tabSpec2.SetIndicator("Settings"); intent = new Intent(this, typeof(SettingsActivity)); intent.AddFlags(ActivityFlags.NewTask); tabSpec2.SetContent(intent); tabHost.AddTab(tabSpec1); tabHost.AddTab(tabSpec2); tabHost.CurrentTab = 0; intent = new Intent(this, typeof(LoginActivity)); StartActivity(intent); }
private void SetIndicator(TabHost.TabSpec tabSpec, object item) { (item as IViewModel)?.Settings.Metadata.AddOrUpdate(ViewModelConstants.StateNotNeeded, true); var templateId = _itemTemplateProvider.GetTemplateId(); var selector = _itemTemplateProvider.GetDataTemplateSelector(); if (templateId == null && selector == null) { selector = EmptyTemplateSelector.Instance; } object content = AndroidToolkitExtensions.GetContentView(TabHost, TabHost.Context, item, templateId, selector); if (content == EmptyTemplateSelector.EmptyView) { content = null; if (item is IHasDisplayName) { BindingServiceProvider.BindingProvider.CreateBindingsFromString(tabSpec, "Title DisplayName", null); } else { tabSpec.SetIndicator(item.ToStringSafe("(null)")); } } var view = content as View; if (view == null) { tabSpec.SetIndicator(content.ToStringSafe("(null)")); } else { tabSpec.SetIndicator(view); } }
public void InitializeTab() { TabHost.TabSpec spec1 = tabHost.NewTabSpec("Info"); spec1.SetContent(Resource.Id.realtabcontent); spec1.SetIndicator(this.Activity.LayoutInflater.Inflate(Resource.Layout.invoice_tab_button_header, null)); tabHost.AddTab(spec1); TabHost.TabSpec spec2 = tabHost.NewTabSpec("Details"); spec2.SetContent(Resource.Id.tab2); spec2.SetIndicator(this.Activity.LayoutInflater.Inflate(Resource.Layout.invoice_tab_button_details, null)); tabHost.AddTab(spec2); for (int i = 0; i < tabHost.TabWidget.ChildCount; i++) { View tab = tabHost.TabWidget.GetChildAt(i); tab.SetBackgroundResource(Resource.Drawable.main_button_selector); tab.SetMinimumHeight(18); } var ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.realtabcontent, invoiceTabHeader); ft.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft.Commit(); var ft1 = FragmentManager.BeginTransaction(); ft1.Replace(Resource.Id.tab2, invoiceTabDetails); ft1.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade); ft1.Commit(); }
protected void AddTab <TFragment>(Bundle args, IMvxViewModel viewModel, TabHost.TabSpec tabSpec) { var tabInfo = new TabInfo(tabSpec.Tag, typeof(TFragment), args, viewModel); AddTab(this, _tabHost, tabSpec, tabInfo); _lookup.Add(tabInfo.Tag, tabInfo); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); TabHost tabHost = (TabHost)FindViewById(Resource.Id.tabHost); tabHost.Setup(); TabHost.TabSpec tabSpec = tabHost.NewTabSpec("xp1"); tabSpec.SetContent(Resource.Id.linear_layout_ports_config_xp1); tabSpec.SetIndicator("XP1"); tabHost.AddTab(tabSpec); tabSpec = tabHost.NewTabSpec("xp2"); tabSpec.SetContent(Resource.Id.linear_layout_ports_config_xp2); tabSpec.SetIndicator("XP2"); tabHost.AddTab(tabSpec); tabSpec = tabHost.NewTabSpec("xt2"); tabSpec.SetContent(Resource.Id.linear_layout_ports_config_xt2); tabSpec.SetIndicator("XT2"); tabHost.AddTab(tabSpec); tabSpec = tabHost.NewTabSpec("xp56"); tabSpec.SetContent(Resource.Id.linear_layout_ports_config_xp56); tabSpec.SetIndicator("XP5/6"); tabHost.AddTab(tabSpec); tabHost.CurrentTab = 0; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.Index); TabHost tab = FindViewById <TabHost>(Resource.Id.tabHost1); tab.Setup(); TabHost.TabSpec spec1 = tab.NewTabSpec("主页"); spec1.SetContent(Resource.Id.layoutIndex); spec1.SetIndicator("主页"); TabHost.TabSpec spec2 = tab.NewTabSpec("书篮"); spec2.SetContent(Resource.Id.layoutBookbasket); spec2.SetIndicator("书篮"); TabHost.TabSpec spec3 = tab.NewTabSpec("个人中心"); spec3.SetContent(Resource.Id.layoutPrivate); spec3.SetIndicator("个人中心"); tab.AddTab(spec1); tab.AddTab(spec2); tab.AddTab(spec3); TabBookBasket(); TabIndex(); TabPrivate(); }
public TabHost.TabSpec SetIndicator(TabHost.TabSpec tabSpec, string text) { var view = LayoutInflater.FromContext(Application.Context).Inflate(Resource.Layout.TabIndicator, null); view.FindViewById <TextView>(Resource.Id.Text).Text = text; return(tabSpec.SetIndicator(view)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AssignmentsTabsLayout); tabHost = FindViewById <TabHost> (Resource.Id.assingmentTabHost); //In order to use tabs outside of a TabActivity I have to use this local activity manager and dispatch create the savedInstanceState localManger = new LocalActivityManager(this, true); localManger.DispatchCreate(savedInstanceState); tabHost.Setup(localManger); TabHost.TabSpec assignmentsSpec = tabHost.NewTabSpec("list"); Intent assignmentIntent = new Intent(this, typeof(AssignmentsActivity)); assignmentsSpec.SetContent(assignmentIntent); assignmentsSpec.SetIndicator("list"); TabHost.TabSpec mapViewSpec = tabHost.NewTabSpec("map"); Intent mapViewIntent = new Intent(this, typeof(MapViewActivity)); mapViewSpec.SetContent(mapViewIntent); mapViewSpec.SetIndicator("map"); tabHost.AddTab(assignmentsSpec); tabHost.AddTab(mapViewSpec); tabHost.TabChanged += (sender, e) => { if (tabHost.CurrentTab == 0) { MapData = null; } }; try { if (savedInstanceState != null) { if (savedInstanceState.ContainsKey(Constants.CurrentTab)) { var currentTab = savedInstanceState.GetInt(Constants.CurrentTab, 0); tabHost.CurrentTab = currentTab; } else { tabHost.CurrentTab = 0; } MapData = savedInstanceState.ContainsKey("mapData") ? (MapDataWrapper)savedInstanceState.GetSerializable("mapData") : null; } else { MapData = null; tabHost.CurrentTab = 0; } } catch (Exception) { tabHost.CurrentTab = 0; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); TabHost tabs = (TabHost)FindViewById(Resource.Id.TabHost01); tabs.Setup(); TabHost.TabSpec spec1 = tabs.NewTabSpec("tag01"); spec1.SetContent(Resource.Id.AnalogClock01); spec1.SetIndicator("Analog Clock"); tabs.AddTab(spec1); TabHost.TabSpec spec2 = tabs.NewTabSpec("tag02"); spec2.SetContent(Resource.Id.DigitalClock01); spec2.SetIndicator("Digital Clock"); tabs.AddTab(spec2); TabHost.TabSpec spec3 = tabs.NewTabSpec("tag03"); spec3.SetContent(Resource.Id.imagenview1); spec3.SetIndicator("Imagen"); tabs.AddTab(spec3); TabHost.TabSpec spec4 = tabs.NewTabSpec("tag04"); spec4.SetContent(Resource.Id.textview2); spec4.SetIndicator("Texto"); tabs.AddTab(spec4); TabHost.TabSpec spec5 = tabs.NewTabSpec("tag05"); spec5.SetContent(Resource.Id.btn); spec5.SetIndicator("Boton"); tabs.AddTab(spec5); Button btn1 = FindViewById <Button>(Resource.Id.btn); btn1.Click += delegate { var progressDialog = ProgressDialog.Show(this, "Corriendo", "Espera...", true); new Thread(new ThreadStart(delegate { Thread.Sleep(5000); RunOnUiThread(() => progressDialog.Hide()); })).Start(); new AlertDialog.Builder(this) .SetTitle("Alerta") .SetMessage("Presiona Ok para Continuar") .SetPositiveButton("Ok", delegate { Toast.MakeText(this, "Se presiono Aceptar", ToastLength.Short).Show(); }) .SetNegativeButton("Cancel", delegate { Toast.MakeText(this, "Se presiono Cancelar", ToastLength.Short).Show(); }).Show(); }; }
public void AddTab(TabHost.TabSpec tabSpec, Class clss, Bundle args) { tabSpec.SetContent(new DummyTabFactory(_context)); var tag = tabSpec.Tag; var info = new TabInfo(tag, clss, args); _tabs.Add(info); _tabHost.AddTab(tabSpec); NotifyDataSetChanged(); }
private void InitTabs() { mTabHost = this.View.FindViewById <FragmentTabHost>(Android.Resource.Id.TabHost); mTabHost.Setup(this.Activity, this.Activity.SupportFragmentManager, Resource.Id.realtabcontent); TabHost.TabSpec tabSpec1 = this.SetIndicator(mTabHost.NewTabSpec("Scanner"), "ɨһɨ"); mTabHost.AddTab(tabSpec1, Class.FromType(typeof(ScannerFragment)), null); TabHost.TabSpec tabSpec2 = this.SetIndicator(mTabHost.NewTabSpec("Main"), "µ¯´°²âÊÔ"); mTabHost.AddTab(tabSpec2, Class.FromType(typeof(MainFragment)), null); }
public void AddTab(TabHost.TabSpec tabSpec, System.Type clss, Bundle args) { tabSpec.SetContent(new DummyTabFactory(mContext)); string tag = tabSpec.GetTag(); TabInfo info = new TabInfo(tag, clss, args); mTabs.Add(info); mTabHost.AddTab(tabSpec); NotifyDataSetChanged(); }
private void CreateTab(Type activityType, string tag, string label) { Intent intent = new Intent(this, activityType); intent.AddFlags(ActivityFlags.NewTask); TabHost.TabSpec spec = TabHost.NewTabSpec(tag); spec.SetIndicator(label); spec.SetContent(intent); TabHost.AddTab(spec); }
private void CreateTab(Type activityType, string tag, string lavel, int drawableId, TabHost tabHost) { Intent intent = new Intent(this, activityType); intent.AddFlags(ActivityFlags.NewTask); TabHost.TabSpec specs = tabHost.NewTabSpec(tag); Drawable drawableIcon = Resources.GetDrawable(drawableId); specs.SetIndicator(lavel, drawableIcon); specs.SetContent(intent); tabHost.AddTab(specs); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); TabHost tabHost = FindViewById(Resource.Id.tabhost_sample) as TabHost; tabHost.Setup(); TabHost.TabSpec tabSpec1 = tabHost.NewTabSpec("SampleTab1"); tabSpec1.SetContent(Resource.Id.tab_sampletab1); tabSpec1.SetIndicator("SampleTab1"); TabHost.TabSpec tabSpec2 = tabHost.NewTabSpec("SampleTab2"); tabSpec2.SetContent(Resource.Id.tab_sampletab2); tabSpec2.SetIndicator("SampleTab2"); tabHost.AddTab(tabSpec1); tabHost.AddTab(tabSpec2); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); MenuId = Resource.Menu.mainmenu; SetContentView(Resource.Layout.fragment_tabs); _tabHost = FindViewById <TabHost>(Android.Resource.Id.TabHost); _tabHost.Setup(); _viewPager = FindViewById <ViewPager>(Resource.Id.pager); _tabsAdapter = new TabsAdapter(this, _tabHost, _viewPager); LegacyBar = FindViewById <Library.Bar.LegacyBar>(Resource.Id.actionbar); LegacyBar.Title = "Look Fragments"; AddHomeAction(typeof(HomeActivity), Resource.Drawable.icon); var action = new MenuItemLegacyBarAction(this, Resource.Id.menu_search, Resource.Drawable.ic_action_search_dark, Resource.String.menu_string_search); LegacyBar.AddAction(action); TabHost.TabSpec spec = _tabHost.NewTabSpec("tv"); spec.SetIndicator("Tab 1", Resources.GetDrawable(Resource.Drawable.icon)); _tabsAdapter.AddTab(spec, Class.FromType(typeof(FramgmentTab1)), null); spec = _tabHost.NewTabSpec("tab2"); spec.SetIndicator("Tab 2", Resources.GetDrawable(Resource.Drawable.icon)); _tabsAdapter.AddTab(spec, Class.FromType(typeof(FramgmentTab2)), null); if (bundle != null) { _tabHost.SetCurrentTabByTag(bundle.GetString("tab")); } else { _tabHost.CurrentTab = 0; } }
private void makeTabs() { TabHost tabs = (TabHost)FindViewById(Resource.Id.tabhost); tabs.Setup(); TabHost.TabSpec spec = tabs.NewTabSpec("tag1"); spec.SetContent(Resource.Id.tab1); spec.SetIndicator("Tasks"); tabs.AddTab(spec); spec = tabs.NewTabSpec("tag2"); spec.SetContent(Resource.Id.tab2); spec.SetIndicator("Address"); tabs.AddTab(spec); spec = tabs.NewTabSpec("tag3"); spec.SetContent(Resource.Id.tab3); spec.SetIndicator("Map"); tabs.AddTab(spec); }
public void InitTab() { host.Setup(); TabHost.TabSpec spec = host.NewTabSpec("Jobs"); spec.SetContent(Resource.Id.TabOne); spec.SetIndicator("Jobs"); host.AddTab(spec); spec = host.NewTabSpec("History"); spec.SetContent(Resource.Id.TabTwo); spec.SetIndicator("History"); host.AddTab(spec); spec = host.NewTabSpec("Settings"); spec.SetContent(Resource.Id.TabThree); spec.SetIndicator("Settings"); host.AddTab(spec); }
void AddTab(string labelId, int drawableId, System.Type c) { var tabHost = TabHost; var intent = new Intent(this, c); TabHost.TabSpec spec = tabHost.NewTabSpec(string.Format("tab{0}", labelId)); var tabIndicator = LayoutInflater.From(this).Inflate(Resource.Layout.tab_indicator, TabWidget, false); var title = tabIndicator.FindViewById <TextView>(Resource.Id.title); title.Text = labelId; var icon = tabIndicator.FindViewById <ImageView>(Resource.Id.icon); icon.SetImageResource(drawableId); spec.SetIndicator(tabIndicator); spec.SetContent(intent); tabHost.AddTab(spec); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.OmnicTabsView); TabHost.TabSpec spec = TabHost.NewTabSpec("child1"); spec.SetIndicator("1"); spec.SetContent(this.CreateIntentFor(FirstViewModel.Child1)); TabHost.AddTab(spec); spec = TabHost.NewTabSpec("child2"); spec.SetIndicator("2"); spec.SetContent(this.CreateIntentFor(FirstViewModel.Child2)); TabHost.AddTab(spec); spec = TabHost.NewTabSpec("child3"); spec.SetIndicator("3"); spec.SetContent(this.CreateIntentFor(FirstViewModel.Child3)); TabHost.AddTab(spec); }
public void AddTab(TabHost.TabSpec tabSpec, Class clss, Bundle args) { tabSpec.SetContent(new DummyTabFactory(_activity)); var tag = tabSpec.Tag; var info = new TabInfo(tag, clss, args); // Check to see if we already have a fragment for this tab, probably // from a previously saved state. If so, deactivate it, because our // initial state is that a tab isn't shown. info.fragment = _activity.SupportFragmentManager.FindFragmentByTag(tag); if (info.fragment != null && !info.fragment.IsDetached) { var ft = _activity.SupportFragmentManager.BeginTransaction(); ft.Detach(info.fragment); ft.Commit(); } _tabs.Add(tag, info); _tabHost.AddTab(tabSpec); }
/// <summary> /// Initialize the tabs and set views and identifiers for the tabs /// </summary> /// <param name="view">View.</param> public void InitializeTab(View view) { TabHost.TabSpec spec1 = mTabHost.NewTabSpec("Monthly"); spec1.SetContent(Resource.Id.realtabcontent); spec1.SetIndicator(this.Activity.LayoutInflater.Inflate(Resource.Layout.statistic_tab_button_month, null)); //"Monthly", Resource.Drawable.statistic_date48); mTabHost.AddTab(spec1); TabHost.TabSpec spec2 = mTabHost.NewTabSpec("By Date"); spec2.SetContent(Resource.Id.realtabcontent); spec2.SetIndicator(this.Activity.LayoutInflater.Inflate(Resource.Layout.statistic_tab_button_date, null)); //"By Date", Resource.Drawable.statistic_month); mTabHost.AddTab(spec2); for (int i = 0; i < mTabHost.TabWidget.ChildCount; i++) { View tab = mTabHost.TabWidget.GetChildAt(i); tab.SetBackgroundResource(Resource.Drawable.main_button_selector); tab.SetMinimumHeight(18); } mTabHost.SetCurrentTabByTag("By Date"); mTabHost.SetCurrentTabByTag("Monthly"); }
private static void AddTab(MvxTabsFragmentActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) { // Attach a Tab view factory to the spec tabSpec.SetContent(new TabFactory(activity)); string tag = tabSpec.Tag; // Check to see if we already have a CachedFragment for this tab, probably // from a previously saved state. If so, deactivate it, because our // initial state is that a tab isn't shown. tabInfo.CachedFragment = activity.SupportFragmentManager.FindFragmentByTag(tag); if (tabInfo.CachedFragment != null && !tabInfo.CachedFragment.IsDetached) { var ft = activity.SupportFragmentManager.BeginTransaction(); ft.Detach(tabInfo.CachedFragment); ft.Commit(); activity.SupportFragmentManager.ExecutePendingTransactions(); } tabHost.AddTab(tabSpec); }
public TabInfo(object item, TabHost.TabSpec tabSpec, object content) { Item = item; TabSpec = tabSpec; Content = content; }
private void SetHomeScreen() { SetContentView(Resource.Layout.HomeScreen); lbName = FindViewById <TextView>(Resource.Id.lbName); lbCompleted = FindViewById <TextView>(Resource.Id.lbCompleted); lbSkipped = FindViewById <TextView>(Resource.Id.lbSkipped); tbComment = FindViewById <EditText>(Resource.Id.tbTaskComment); lbTaskText = FindViewById <TextView>(Resource.Id.lbTaskText); lbWait = FindViewById <TextView>(Resource.Id.lbWait); layoutTask = FindViewById <ScrollView>(Resource.Id.scroll); layoutHome = FindViewById <LinearLayout>(Resource.Id.tab1); lbTaskRank = FindViewById <TextView>(Resource.Id.lbRank); try { var tabs = (TabHost)FindViewById <TabHost>(Resource.Id.tabHost1); tabs.Setup(); TabHost.TabSpec spec = tabs.NewTabSpec("tag1"); spec.SetContent(Resource.Id.tab1); spec.SetIndicator("Домой"); tabs.AddTab(spec); spec = tabs.NewTabSpec("tag2"); spec.SetContent(Resource.Id.tab2); spec.SetIndicator("Задание"); tabs.AddTab(spec); tabs.SetCurrentTabByTag("tag1"); } catch (Exception ex) { Logger.Log("error23:{0}", ex); } var layout = FindViewById <ScrollView>(Resource.Id.scroll); var btCloseTask = FindViewById <Button>(Resource.Id.btCloseTask); btCloseTask.Click += (o, k) => { if (_storage.CurrentTask == null) { return; } HideTask(); Task.Factory.StartNew(() => _net.SendTaskDone(false)). ContinueWith((t) => { UpdateUserDataView(); }, TaskScheduler.FromCurrentSynchronizationContext()); }; var btSendTask = FindViewById <Button>(Resource.Id.btSendComment); btSendTask.Click += (o, k) => { //var btn = new Button(this); //btn.SetText("New Button", TextView.BufferType.Normal); //layout.AddView(btn); if (_storage.CurrentTask == null) { return; } HideTask();//->Close() Task.Factory.StartNew(() => _net.SendTaskDone(true, (byte)0, tbComment.Text.Length > 0 ? tbComment.Text : "")). ContinueWith((t) => { UpdateUserDataView(); }, TaskScheduler.FromCurrentSynchronizationContext()); }; UpdateUserDataView(); _storage.OnDataUpdate += () => { RunOnUiThread(() => UpdateUserDataView()); }; timer = new Timer(); timer.Interval = 10000; timer.Elapsed += (o, k) => { if (_storage.CurrentTask == null) { Task.Factory.StartNew(() => _net.GetTask()); Logger.Log("try get new tasks..."); } timer.Enabled = true; }; timer.Start(); }
private void AddNewTab(string tabSpecName, string tabSpecIndicator, int drawableResource, Intent intent) { //Create an Intent to Launc an Acitvity for the tab (to be reused) intent.AddFlags(ActivityFlags.NewTask); //Initialize a TabSpec for each tab and add it to the TabHost _spec = TabHost.NewTabSpec(tabSpecName); _spec.SetIndicator(tabSpecIndicator, Resources.GetDrawable(drawableResource)); _spec.SetContent(intent); TabHost.AddTab(_spec); }
// Called when the activity is first created. protected override void OnCreate(Bundle savedInstanceState) { Log.Debug(TAG, "onCreate"); base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.Fullscreen); Window.AddFlags(WindowManagerFlags.KeepScreenOn); RequestedOrientation = ScreenOrientation.Landscape; populateCameraOrientations(); SetContentView(Resource.Layout.tabhost); IntentFilter receiverFilter = new IntentFilter(Intent.ActionHeadsetPlug); receiver = new BroadcastReceiverAnonymousInnerClassHelper(this); RegisterReceiver(receiver, receiverFilter); mTabHost = TabHost; // Main tab mTabSpecVideo = mTabHost.NewTabSpec("tab_video"); mTabSpecVideo.SetIndicator("Main"); mTabSpecVideo.SetContent(Resource.Id.tab_video); mTabHost.AddTab(mTabSpecVideo); // Shared config tab mTabHost = TabHost; mTabSpecConfig = mTabHost.NewTabSpec("tab_config"); mTabSpecConfig.SetIndicator("Settings"); mTabSpecConfig.SetContent(Resource.Id.tab_config); mTabHost.AddTab(mTabSpecConfig); TabHost.TabSpec mTabv; mTabv = mTabHost.NewTabSpec("tab_vconfig"); mTabv.SetIndicator("Video"); mTabv.SetContent(Resource.Id.tab_vconfig); mTabHost.AddTab(mTabv); TabHost.TabSpec mTaba; mTaba = mTabHost.NewTabSpec("tab_aconfig"); mTaba.SetIndicator("Audio"); mTaba.SetContent(Resource.Id.tab_aconfig); mTabHost.AddTab(mTaba); int childCount = mTabHost.TabWidget.ChildCount; for (int i = 0; i < childCount; i++) { mTabHost.TabWidget.GetChildAt(i).LayoutParameters.Height = 50; } orientationListener = new OrientationEventListenerAnonymousInnerClassHelper(this, SensorDelay.Ui); orientationListener.Enable(); // Create a folder named webrtc in /scard for debugging webrtcDebugDir = Android.OS.Environment.ExternalStorageDirectory.ToString() + webrtcName; File webrtcDir = new File(webrtcDebugDir); if (!webrtcDir.Exists() && webrtcDir.Mkdir() == false) { Log.Verbose(TAG, "Failed to create " + webrtcDebugDir); } else if (!webrtcDir.IsAbsolute) { Log.Verbose(TAG, webrtcDebugDir + " exists but not a folder"); webrtcDebugDir = null; } startMain(); if (AUTO_CALL_RESTART_DELAY_MS > 0) { StartOrStop(); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); historyViewModel = ServiceContainer.Resolve <HistoryViewModel> (); menuViewModel = ServiceContainer.Resolve <MenuViewModel> (); var view = inflater.Inflate(Resource.Layout.HistoryFragmentLayout, null, true); searchText = view.FindViewById <EditText> (Resource.Id.historySearchText); searchText.TextChanged += (sender, e) => { if (historySearchAdapter != null) { historySearchAdapter.FilterItems(searchText.Text); historySearchAdapter.NotifyDataSetChanged(); } }; var clearSearch = view.FindViewById <ImageButton> (Resource.Id.historyClearSearch); clearSearch.Click += (sender, e) => searchText.Text = string.Empty; tabHost = view.FindViewById <TabHost> (Resource.Id.historyTabHost); historyListView = view.FindViewById <ListView> (Resource.Id.historyListView); localManger = new LocalActivityManager(Activity, true); localManger.DispatchCreate(savedInstanceState); tabHost.Setup(localManger); var dateIndicator = CreateTab("DATE"); TabHost.TabSpec dateTab = tabHost.NewTabSpec("Date"); dateTab.SetIndicator(dateIndicator); dateTab.SetContent(new TabContent(new TextView(tabHost.Context))); var callsIndicator = CreateTab("CALLS"); TabHost.TabSpec callsTab = tabHost.NewTabSpec("Calls"); callsTab.SetIndicator(callsIndicator); callsTab.SetContent(new TabContent(new TextView(tabHost.Context))); var assignmentIndicator = CreateTab("ASSIGNMENTS"); TabHost.TabSpec assignments = tabHost.NewTabSpec("Assignments"); assignments.SetIndicator(assignmentIndicator); assignments.SetContent(new TabContent(new TextView(tabHost.Context))); tabHost.AddTab(dateTab); tabHost.AddTab(callsTab); tabHost.AddTab(assignments); tabHost.TabChanged += (sender, e) => { if (History != null) { switch (tabHost.CurrentTab) { case 0: historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.OrderBy(h => h.Date).ToList()); break; case 1: historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.Where(h => h.Type == AssignmentHistoryType.PhoneCall).ToList()); break; default: historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.Where(h => h.Type == AssignmentHistoryType.Assignment).ToList()); break; } historySearchAdapter.Assignment = Assignment; historyListView.Adapter = historySearchAdapter; } }; if (History != null) { historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.OrderBy(a => a.Date).ToList()); historySearchAdapter.Assignment = Assignment; historyListView.Adapter = historySearchAdapter; } historyListView.ItemClick += (sender, e) => { var intent = new Intent(Activity, typeof(SummaryHistoryActivity)); historyViewModel.SelectedAssignmentHistory = History.ElementAtOrDefault(e.Position); menuViewModel.MenuIndex = 0; StartActivity(intent); }; return(view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.BookDetail); string updateBookId = ""; Button borrowButton = FindViewById <Button>(Resource.Id.borrow1); Button collectionButton = FindViewById <Button>(Resource.Id.collection1); TabHost tab = FindViewById <TabHost>(Resource.Id.tabHost123); TextView bookSummary = FindViewById <TextView>(Resource.Id.textView_BookSummary); //内容概要 TextView bookCatalog = FindViewById <TextView>(Resource.Id.textView_BookCatalog); //本书目录 TextView bookClassId = FindViewById <TextView>(Resource.Id.textView_BookClassId); TextView bookPrice = FindViewById <TextView>(Resource.Id.textView_BookPrice); TextView bookPress = FindViewById <TextView>(Resource.Id.textView_BookPress); TextView bookClassification = FindViewById <TextView>(Resource.Id.textView_BookClassification); TextView bookAuthor = FindViewById <TextView>(Resource.Id.bookDetailAuthor); TextView bookName = FindViewById <TextView>(Resource.Id.bookDetailBookname); bool totalbooknumber2 = false; bool renewdays3 = false; bool notrenewdays4 = false; bool returncheck5 = false; ISharedPreferences LoginSP = GetSharedPreferences("LoginData", FileCreationMode.Private); string PhoneNum = LoginSP.GetString("PhoneNum", null); //获取电话号码 string thebookClassId = Intent.GetStringExtra("BookClassId"); string PersonTotalBookResult = PersonalTotalBookData.Post("http://115.159.145.115/PersonalTotalBook.php/", PhoneNum); //检查个人借书总数是否超过规定 string personaltotalbooknumber = PersonTotalBookResult; string RenewDaysResult = RenewDaysData.Post("http://115.159.145.115/RenewDays.php/", PhoneNum); //检查已续借的书是否过期 string renewdays = RenewDaysResult; string NotRenewDaysResult = NotRenewDaysData.Post("http://115.159.145.115/NotRenewDays.php/", PhoneNum); //检查未续借的书是否过期 string notrenewdays = NotRenewDaysResult; string result = BookDetailData.Post("http://115.159.145.115/BookDetail.php/", thebookClassId); var book = JsonConvert.DeserializeObject <BookClass>(result); //本类书详情 string result1 = BookDetailData.Post("http://115.159.145.115/ReturnCheck.php/", thebookClassId); var returncheck = JsonConvert.DeserializeObject <List <ReturnCheck> >(result1); //读借书信息 if (personaltotalbooknumber != null) { int thetotalbooknumber = 0; int.TryParse(personaltotalbooknumber, out thetotalbooknumber); if (thetotalbooknumber >= 0 && thetotalbooknumber < 10) { //符合规定,可以借书 totalbooknumber2 = true; } else { //不能借书 totalbooknumber2 = false; } } if (renewdays != null) { int therenewdays = 0; int.TryParse(renewdays, out therenewdays); if (therenewdays >= 0 && therenewdays <= 20) { //符合规定,可以借书 renewdays3 = true; } else { //超过续借日期,不能借书 renewdays3 = false; } } else { //可以借书 renewdays3 = true; } if (notrenewdays != null) { int thenotrenewdays = 0; int.TryParse(notrenewdays, out thenotrenewdays); if (thenotrenewdays >= 0 && thenotrenewdays <= 10) { //可以借书 notrenewdays4 = true; } else { //超期未还,不能借书 notrenewdays4 = false; } } else { //可以借书 notrenewdays4 = true; } int judgePhoneNum = 0; int judge = 1; //判断该类书是否被借完 int judgeRenew = 0; //判断是本书是否续借 if (returncheck.Count == 0) { //无法传BookID string QueryIdResult = BookDetailData.Post("http://115.159.145.115/QueryId.php/", thebookClassId); var queryid = JsonConvert.DeserializeObject <List <QueryId> >(QueryIdResult); foreach (QueryId b in queryid) { updateBookId = b.BookId; } returncheck5 = true; } else { foreach (ReturnCheck a in returncheck) { if (a.ReturnFlag == "1") { updateBookId = a.BookId; //可以借书 returncheck5 = true; } else if (a.PhoneNum == PhoneNum && a.ReturnFlag == "0") { if (a.IfRenew == "0") { judgeRenew = 0; //本书没有被续借 } else { judgeRenew = 1; //本书已经被续借 } updateBookId = a.BookId; returncheck5 = false; judgePhoneNum = 1; //还书或续借 } else { //又不可以借,又不可以还 //该类书已经被借完 judge = 0; } } } bookAuthor.Text = book.BookAuthor; //标题:作者 bookName.Text = book.BookName; //标题:书名 bookSummary.Text = book.BookSummary; //Tab1:内容概要 bookCatalog.Text = book.BookCatalog; //Tab2:本书目录 bookClassId.Text = "ISBN :" + book.BookClassId; bookPrice.Text = "价 格:" + book.BookPrice; bookPress.Text = "出版社:" + book.BookPress; bookClassification.Text = "分 类:" + book.BookClassification; Picasso.With(this).Load(book.ImageUrl).Into(FindViewById <ImageView>(Resource.Id.imageView_bookImage)); tab.Setup(); TabHost.TabSpec spec1 = tab.NewTabSpec("tab1"); spec1.SetContent(Resource.Id.layoutBookSummary); spec1.SetIndicator("内容概要"); TabHost.TabSpec spec2 = tab.NewTabSpec("tab2"); spec2.SetContent(Resource.Id.layoutBookCatalog); spec2.SetIndicator("本书目录"); TabHost.TabSpec spec3 = tab.NewTabSpec("tab3"); spec3.SetContent(Resource.Id.layoutIntroduction); spec3.SetIndicator("发行简介"); tab.AddTab(spec1); tab.AddTab(spec2); tab.AddTab(spec3); if (returncheck5 == false && judgePhoneNum == 1) { borrowButton.Text = "还书"; borrowButton.Click += (s, e) => { var Dialog = new AlertDialog.Builder(this); Dialog.SetMessage("确认要还此书?"); Dialog.SetNeutralButton("确认", delegate { ThisBook thisbook = new ThisBook(); thisbook.BookId = updateBookId; thisbook.PhoneNum = PhoneNum; var ReturnJson = JsonConvert.SerializeObject(thisbook); Intent intent = new Intent(this, typeof(ReturnReader)); intent.PutExtra("ReturnBook", "[" + ReturnJson + "]"); StartActivity(intent); }); Dialog.SetNegativeButton("取消", delegate { }); Dialog.Show(); }; if (judgeRenew == 0) //没有被续借 { collectionButton.Text = "续借"; collectionButton.Click += (s, e) => { var Dialog = new AlertDialog.Builder(this); Dialog.SetMessage("确认续借此书?"); Dialog.SetNeutralButton("确认", delegate { string theupdatesuccess = UpdateRenewData.Post("http://115.159.145.115/Renew.php/", updateBookId, PhoneNum); if (theupdatesuccess == "success") { Toast.MakeText(this, "续借成功!", ToastLength.Short).Show(); collectionButton.Enabled = false; } else { Toast.MakeText(this, "抱歉,续借失败!", ToastLength.Short).Show(); } }); Dialog.SetNegativeButton("取消", delegate { }); Dialog.Show(); }; } else if (judgeRenew == 1) { collectionButton.Text = "续借"; collectionButton.Enabled = false; Toast.MakeText(this, "您已续借此书,无法再次续借!", ToastLength.Short).Show(); } } else if (judge == 1 && totalbooknumber2 == true && renewdays3 == true && notrenewdays4 == true && returncheck5 == true) { borrowButton.Text = "借书"; borrowButton.Click += (s, e) => { var Dialog = new AlertDialog.Builder(this); Dialog.SetMessage("确认借阅此书?"); Dialog.SetNeutralButton("确认", delegate { ThisBook thisbook = new ThisBook(); thisbook.BookId = updateBookId; thisbook.PhoneNum = PhoneNum; var ReturnJson = JsonConvert.SerializeObject(thisbook); Intent ActLogin = new Intent(this, typeof(BorrowReader)); ActLogin.PutExtra("BorrowInfo", "[" + ReturnJson + "]"); StartActivity(ActLogin); }); Dialog.SetNegativeButton("取消", delegate { }); Dialog.Show(); }; collectionButton.Text = "加入书篮"; if (AddToBookBasketData.Post("http://115.159.145.115/IfInBookBasket.php/", PhoneNum, book.BookClassId) != "NotIn") { collectionButton.Enabled = false; } collectionButton.Click += (s, e) => { var Dialog = new AlertDialog.Builder(this); Dialog.SetMessage("确认将此书加入书栏?"); Dialog.SetNeutralButton("确认", delegate { string res = AddToBookBasketData.Post("http://115.159.145.115/AddToBookBasket.php", PhoneNum, book.BookClassId); if (res == "Success") { Toast.MakeText(this, "成功加入书栏!", ToastLength.Short).Show(); collectionButton.Enabled = false; } }); Dialog.SetNegativeButton("取消", delegate { }); Dialog.Show(); }; } else if (judge == 0) { borrowButton.Text = "借书"; collectionButton.Text = "加入书篮"; borrowButton.Enabled = false; collectionButton.Enabled = false; Toast.MakeText(this, "抱歉,此类书已经被借完!您无法借阅此书!", ToastLength.Short).Show(); } else if (totalbooknumber2 == false) { borrowButton.Text = "借书"; collectionButton.Text = "加入书篮"; borrowButton.Enabled = false; collectionButton.Enabled = false; Toast.MakeText(this, "抱歉,您的借阅书本数量已满十本!您无法借阅此书!", ToastLength.Short).Show(); } else if (renewdays3 == false) { borrowButton.Text = "借书"; collectionButton.Text = "加入书篮"; borrowButton.Enabled = false; collectionButton.Enabled = false; Toast.MakeText(this, "抱歉,您有续借图书超期未还!您无法借阅此书!", ToastLength.Short).Show(); } else if (notrenewdays4 == false) { borrowButton.Text = "借书"; collectionButton.Text = "加入书篮"; borrowButton.Enabled = false; collectionButton.Enabled = false; Toast.MakeText(this, "抱歉,您有借阅图书超期未还!您无法借阅此书!", ToastLength.Short).Show(); } }