当前位置: 首页>>代码示例>>C#>>正文


C# ImageButton.SetBackgroundResource方法代码示例

本文整理汇总了C#中ImageButton.SetBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:C# ImageButton.SetBackgroundResource方法的具体用法?C# ImageButton.SetBackgroundResource怎么用?C# ImageButton.SetBackgroundResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageButton的用法示例。


在下文中一共展示了ImageButton.SetBackgroundResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateView

		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			mapView = base.OnCreateView (inflater, container, savedInstanceState);

			// Save ScreenController for later use
			ctrl = ((GameController)this.Activity);

			RelativeLayout view = new RelativeLayout(ctrl);
			view.AddView(mapView, new RelativeLayout.LayoutParams(-1, -1));

//			var view = inflater.Inflate(Resource.Layout.ScreenMap, container, false);
//
//			mapView = new MapView(ctrl);
//			mapView.OnCreate(savedInstanceState);
//
			// Set all relevant data for map

			_zoom = (float)Main.Prefs.GetDouble("MapZoom", 16);

			_map = this.Map;
			_map.MapType = GoogleMap.MapTypeNormal;
			_map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(Main.GPS.Location.Latitude, Main.GPS.Location.Longitude), _zoom));
			_map.MyLocationEnabled = true;
			_map.BuildingsEnabled = true;
			_map.UiSettings.ZoomControlsEnabled = false;
			_map.UiSettings.MyLocationButtonEnabled = false;
			_map.UiSettings.CompassEnabled = false;
			_map.UiSettings.TiltGesturesEnabled = false;
			_map.UiSettings.RotateGesturesEnabled = false;
			_map.MapClick += OnMapClick;

			// Create tile layers
			_osmTileLayer = new OsmTileProvider("http://a.tile.openstreetmap.org/{0}/{1}/{2}.png");
			_ocmTileLayer = new OsmTileProvider("http://c.tile.opencyclemap.org/cycle/{0}/{1}/{2}.png");

			// Set selected map type
			SetMapType(Main.Prefs.GetInt("map_source", 0));

			// Create the zones the first time
			CreateZones();

			// Create layout for map buttons
			layoutButtons = new RelativeLayout(ctrl);

			// Button for center menu
			var lp = new RelativeLayout.LayoutParams(64, 64);
			lp.SetMargins(16, 16, 16, 8);
			lp.AddRule(LayoutRules.AlignParentLeft);
			lp.AddRule(LayoutRules.AlignParentTop);

			btnMapCenter = new ImageButton(ctrl);
			btnMapCenter.Id = 1;
			btnMapCenter.SetImageResource(Resource.Drawable.ic_button_center);
			btnMapCenter.SetBackgroundResource(Resource.Drawable.MapButton);
			btnMapCenter.Click += OnMapCenterButtonClick;

			layoutButtons.AddView(btnMapCenter, lp);

			// Button for the orientation: north up or always in direction
			lp = new RelativeLayout.LayoutParams(64, 64);
			lp.SetMargins(16, 8, 16, 16);
			lp.AddRule(LayoutRules.Below, btnMapCenter.Id);
			lp.AddRule(LayoutRules.AlignParentLeft);

			btnMapOrientation = new ImageButton(ctrl);
			if (Main.Prefs.GetBool ("MapOrientationNorth", true))
				btnMapOrientation.SetImageResource (Resource.Drawable.ic_button_orientation_north);
			else
				btnMapOrientation.SetImageResource (Resource.Drawable.ic_button_orientation);
			btnMapOrientation.SetBackgroundResource(Resource.Drawable.MapButton);
			btnMapOrientation.Click += OnMapOrientationButtonClick;

			layoutButtons.AddView(btnMapOrientation, lp);

			// Button for selecting the map type
			lp = new RelativeLayout.LayoutParams(64, 64);
			lp.SetMargins(16, 16, 16, 8);
			lp.AddRule(LayoutRules.AlignParentTop);
			lp.AddRule(LayoutRules.AlignParentRight);

			btnMapType = new ImageButton(ctrl);
			btnMapType.SetImageResource(Resource.Drawable.ic_button_layer);
			btnMapType.SetBackgroundResource(Resource.Drawable.MapButton);
			btnMapType.Click += OnMapTypeButtonClick;

			layoutButtons.AddView(btnMapType, lp);

			view.AddView(layoutButtons);

			return view;
		}
开发者ID:WFoundation,项目名称:WF.Player.Android,代码行数:91,代码来源:GameMapScreen.cs

示例2: SendFollowRequest

//		public static async Task<bool> RepostPost (Post post, UIButton repostButton, UITableView tableView = null, NSIndexPath indexPath = null)
//		{
//			if ((post.userReposter != null && post.userReposter.idUser == Globe.SharedInstance.User.idUser) || post.userPoster.idUser == Globe.SharedInstance.User.idUser || post.isReposted) {
//				return false;
//			}
//
//
//			post.isReposted = true;
//			repostButton.SetImage (UIImage.FromBundle ("refresh"), UIControlState.Normal);
//			repostButton.SetImage (UIImage.FromBundle ("refresh"), UIControlState.Normal);
//			repostButton.SetImage (UIImage.FromBundle ("refresh"), UIControlState.Normal);
//
//
//			try {
//				bool result = await TenServices.RepostPost (post);
//				if (!result) {
//					post.isReposted = false;
//					repostButton.SetImage (UIImage.FromBundle ("Repost"), UIControlState.Normal);
//					repostButton.SetImage (UIImage.FromBundle ("Repost"), UIControlState.Normal);
//					repostButton.SetImage (UIImage.FromBundle ("Repost"), UIControlState.Normal);
//				} else {
//					if (tableView != null && indexPath != null) {
//						tableView.ReloadRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.None);
//					}
//				}
//				return result;
//			} catch (RESTError) {
//				post.isReposted = false;
//				repostButton.SetImage (UIImage.FromBundle ("Repost"), UIControlState.Normal);
//				repostButton.SetImage (UIImage.FromBundle ("Repost"), UIControlState.Normal);
//				repostButton.SetImage (UIImage.FromBundle ("Repost"), UIControlState.Normal);
//			}
//
//
//			return false;
//		}
//
//		public static void DeleteComment (Post post, Comment comment, UITableView tableView, NSIndexPath indexPath, List<Comment> underlyingDataSource)
//		{
//			post.liked = true;
//
//			CATransaction.Begin ();
//
//			tableView.BeginUpdates ();
//
//			CATransaction.CompletionBlock += async delegate {
//				try {
//					bool result = await TenServices.DeleteComment (comment, post);
//					if (!result) {
//
//						underlyingDataSource.Insert (indexPath.Row, comment);
//						tableView.ReloadData ();
//					}
//					return;
//				} catch (RESTError) {
//					Console.WriteLine ("Error service helper");
//				}
//				return;
//			};
//
//			if (tableView.NumberOfRowsInSection (indexPath.Section) == 1) {
//				tableView.DeleteSections (NSIndexSet.FromIndex (indexPath.Section), UITableViewRowAnimation.Left);
//			} else {
//				tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Left);
//			}
//
//			underlyingDataSource.Remove (comment);
//
//			tableView.EndUpdates ();
//
//			CATransaction.Commit ();
//		}


		public static async Task<bool> SendFollowRequest (User user, ImageButton followButton)
		{
			//unfriend
			if (user.friended == Strings.friended_friended) {
				user.friended = Strings.friended_none;
				followButton.SetBackgroundResource (Resource.Drawable.follow);
				try {
					bool result = await TenServices.SendUnfollowRequest (user);
					if (!result) {
						if (user.isprivate) {
							user.friended = Strings.friended_pending;
							followButton.SetBackgroundResource (Resource.Drawable.requested);
						} else {
							user.friended = Strings.friended_friended;
							followButton.SetBackgroundResource (Resource.Drawable.following);
						}
					}
					return result;
				} catch (RESTError) {
					if (user.isprivate) {
						user.friended = Strings.friended_pending;
						followButton.SetBackgroundResource (Resource.Drawable.requested);
					} else {
						user.friended = Strings.friended_friended;
						followButton.SetBackgroundResource (Resource.Drawable.following);
					}
//.........这里部分代码省略.........
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:101,代码来源:TenServiceHelper.cs

示例3: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            SetTheme(Settings.ThemeSetting == 0 ? Resource.Style.MyTheme : Resource.Style.MyThemeDark);

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            m_OriginalTheme = Settings.ThemeSetting;
            m_OriginalAccent = Settings.ThemeAccent;

            Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);

            m_AllTasks = new JavaList<TaskModel>();
            m_EditTaskPosition = 0;

            m_AddButton = FindViewById<ImageButton>(Resource.Id.button_add_task);
            m_MicrophoneButton = FindViewById<ImageButton>(Resource.Id.button_microphone);
            m_TaskEditText = FindViewById<EditText>(Resource.Id.edit_text_new_task);

            ActionBar = FindViewById<ActionBar.ActionBar>(Resource.Id.actionbar);

            //ActionBar.BackgroundDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_background_blue);
            //ActionBar.ItemBackgroundDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_btn_blue);
            //ActionBar.SeparatorColor = Resources.GetColor(Resource.Color.actionbar_separatorcolor_blue);
            ActionBar.Title = "Tasks";
            ActionBar.CurrentActivity = this;
            ActionBar.SetHomeLogo(Resource.Drawable.ic_launcher);
            RegisterForContextMenu(ListView);

            m_TaskEditText.SetOnEditorActionListener(this);

            ListView.ChoiceMode = ChoiceMode.Multiple;

            m_AddButton.Click += (sender, args) => AddNewTask();

            m_AddButton.SetImageResource(Settings.ThemeSetting == 0 ? Resource.Drawable.ic_action_add : Resource.Drawable.ic_action_add_dark);
            m_MicrophoneButton.SetImageResource(Settings.ThemeSetting == 0 ? Resource.Drawable.ic_action_microphone : Resource.Drawable.ic_action_microphone_dark);

            m_AddButton.SetBackgroundResource(Settings.ImageButtonDrawable);
            m_MicrophoneButton.SetBackgroundResource(Settings.ImageButtonDrawable);

            // remove speech if it doesn't exist
            var activities =PackageManager.QueryIntentActivities(new Intent(RecognizerIntent.ActionRecognizeSpeech), 0);
            if (activities.Count == 0)
            {
                m_MicrophoneButton.Visibility = ViewStates.Gone;
            }
            else
            {
                m_MicrophoneButton.Click += (sender, args) => StartVoiceRecognitionActivity();
            }

            m_TextToSpeech = new TextToSpeech(this, this);

            var saveState = LastNonConfigurationInstance as SaveState;
            if (saveState != null)
            {
                m_AllTasks = new JavaList<TaskModel>(saveState.Tasks);
                ListView.Visibility = ViewStates.Visible;
                RunOnUiThread(() => ListAdapter = new TaskAdapter(this, m_AllTasks));
                RunOnUiThread(() => ListView.SetSelection(saveState.LastPosition));
                SetChecks();
                m_TaskEditText.Text = saveState.NewTaskText;
                m_Editing = saveState.Editing;
                m_EditTaskPosition = saveState.EditIndex;
            }
            else
            {
                FlurryAgent.OnPageView();
                FlurryAgent.LogEvent("MainActivity");
                ReloadData(0);
            }

            SetActionBar();
            try
            {
                if(Intent.GetBooleanExtra("CameFromWidget", false))
                {
                    FocusMainText();
                    return;
                }

                if(Intent.Action == TaskWidgetProvider.UpdateIntent)

                if (Intent.ActionSend != Intent.Action || Intent.Type == null)
                    return;

                if ("text/plain" != Intent.Type)
                    return;

                var sharedText = Intent.GetStringExtra(Intent.ExtraText);
                if (!string.IsNullOrEmpty(sharedText))
                {
                    m_TaskEditText.Text = sharedText;
                    m_Editing = false;
                    SetActionBar();
                }
            }
//.........这里部分代码省略.........
开发者ID:SpiderMaster,项目名称:TasksSimplified,代码行数:101,代码来源:MainActivity.cs


注:本文中的ImageButton.SetBackgroundResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。