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


C# ImageView.SetImageResource方法代码示例

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


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

示例1: LikePost

		public static async Task<bool> LikePost (Post post, ImageView likeButton, ListView lsitViewAdaper = null)
		{
			if (post.liked) {
				//todo delete
				likeButton.StartAnimation(AnimationUtils.LoadAnimation(TabHostActivity.GetTabHost(), Resource.Animation.grow));
				MediaPlayer.Create(TabHostActivity.GetTabHost(), Resource.Raw.ticksound).Start();


				likeButton.SetImageResource(Resource.Drawable.likeselected);
				return false;
			}

			if (post.userPoster.idUser != Globe.SharedInstance.User.idUser) {
				post.liked = true;
				likeButton.SetImageResource(Resource.Drawable.likeselected);
	
				try {
					likeButton.StartAnimation(AnimationUtils.LoadAnimation(TabHostActivity.GetTabHost(), Resource.Animation.grow));
					MediaPlayer.Create(TabHostActivity.GetTabHost(), Resource.Raw.ticksound).Start();
					bool result = await TenServices.LikePost (post);
					if (!result) {
						post.liked = false;
						likeButton.SetImageResource(Resource.Drawable.like);
					} 
					return result;
				} catch (RESTError) {
					post.liked = false;
					likeButton.SetImageResource(Resource.Drawable.like);
				}
			}

			return false;
		}
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:33,代码来源:TenServiceHelper.cs

示例2: ShowShortResultAsync

        public async Task ShowShortResultAsync(bool result)
        {
            Toast toast = new Toast(activity);

            ImageView imgView = new ImageView(activity); 
            toast.View = imgView;

            if(result)
                imgView.SetImageResource(Resource.Drawable.ic_thumb_up_black); 
            else
                imgView.SetImageResource(Resource.Drawable.ic_thumb_down_black); 
                

            toast.Show();

            await Task.Delay(RESULT_DISPLAYED_TIME);
            try
            {
                toast.Cancel();
            }
            catch(Exception ex)
            {
                Log.Error("HarmNumb", ex.ToString());
            }
        }
开发者ID:brunnurs,项目名称:HarmNumb,代码行数:25,代码来源:QuizResultHandler.cs

示例3: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.view_cards);

            newDeck = new Deck (2);
            cardList = newDeck.ShuffledList;

            LL = FindViewById<LinearLayout> (Resource.Id.myMain);
            pic = FindViewById<ImageView> (Resource.Id.imageView1);
            picL = FindViewById<ImageView> (Resource.Id.imageViewL);
            picR = FindViewById<ImageView> (Resource.Id.imageViewR);
            var tv = FindViewById<TextView> (Resource.Id.textView1);
            pic.Click += delegate {
                getInfo (pic);
                getInfo (picL);
                getInfo (picR);
                if (count < newDeck.Count) {
                    var card = cardList [count];
                    var id = card.Display;
                    if (count > 0) {
                        var cardL = cardList [count+1];
                        var cardR = cardList [count-1];
                        idL = cardL.Display;
                        idR = cardR.Display;
                    }
                    RunOnUiThread (() => {
                        pic.SetImageResource (id);
                        if (count > 0) {
                            picL.SetImageResource (idL);
                            picR.SetImageResource (idR);
                        }
                        var color = card.Color?"Red":"Black";

                        tv.Text = String.Format ("{0}\n{1}\n{2} - {3} - {4}\n{5}",
                                                 54-count,card.Name, card.Value, card.Suit, color, card.Display);
                    });

                } else {
                    RunOnUiThread (() => pic.SetImageResource (Resource.Drawable.back));
                    count = 0;
                    newDeck = null;
                    newDeck = new Deck (2);
                    cardList = newDeck.ShuffledList;
                    Console.WriteLine ("NEW_GAME");
                }
            };
        }
开发者ID:bny-mobile,项目名称:Cards,代码行数:48,代码来源:ActivityViewCards.cs

示例4: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			// Create your application here
			SetContentView(Resource.Layout.Game);

			mimgHome = FindViewById<ImageView> (Resource.Id.limgGHome);
			mimgCoin = FindViewById<ImageView> (Resource.Id.limgGCoin);
			mbtnOne = FindViewById<Button> (Resource.Id.lbtnGOne);

			mimgHome.SetImageResource (Resource.Drawable.home);
			mimgCoin.SetImageResource (Resource.Drawable.coin_small);

			mtxtCoin = FindViewById<TextView> (Resource.Id.ltxtGCoin);
			mtxtCoin.Text = Convert.ToString(Database.getCoins ());

			mimgHome.Click += (object sender, EventArgs e) => {
				StartActivity(typeof(actMenu));
			};

			mbtnOne.Click += (object sender, EventArgs e) => {
				StartActivity(typeof(actGameFill2));
			};
		}
开发者ID:jejeboom,项目名称:Cebuanizer,代码行数:25,代码来源:actGame.cs

示例5: AddItem

        //here we only have img and text for each item
        //create a RelativeLayout and add it to dic
        //squear image
        public void AddItem(int imgresource,string text,Action OnCellClick)
        {
            RelativeLayout menucell = new RelativeLayout (nn_context);
            menucell.SetPadding (TapUtil.dptodx(padding),TapUtil.dptodx(padding),TapUtil.dptodx(padding),TapUtil.dptodx(padding));
            menucell.LayoutParameters = new LinearLayout.LayoutParams (TapUtil.dptodx(cellwidth),TapUtil.dptodx(cellheight));
            menucell.Click+= (object sender, EventArgs e) => {

                if(OnCellClick!=null){
                    OnCellClick();
                }
            };

            ImageView img = new ImageView (nn_context);
            img.Id = TapUtil.generateViewId ();
            img.LayoutParameters = new RelativeLayout.LayoutParams (TapUtil.dptodx(imagewidth),TapUtil.dptodx(imagewidth));
            //			Bitmap.CreateScaledBitmap(imgresource, TapUtil.dptodx(imagewidth), TapUtil.dptodx(imageheight), false);
            img.SetImageResource (imgresource);
            img.SetBackgroundColor (Color.White);

            TextView textview = new TextView (nn_context);
            RelativeLayout.LayoutParams textviewparam=new RelativeLayout.LayoutParams (TapUtil.dptodx(textwidth),TapUtil.dptodx(textheight));
            textviewparam.AddRule(LayoutRules.RightOf,img.Id);
            textviewparam.LeftMargin = TapUtil.dptodx (space);
            textview.LayoutParameters =textviewparam;
            textview.Text = text;
            textview.SetTypeface (Typeface.Default, TypefaceStyle.Bold);
            textview.SetTextColor(Color.Black);
            textview.Gravity = global::Android.Views.GravityFlags.Center;

            menucell.AddView (img);
            menucell.AddView (textview);

            nn_itemlist.Add (menucell);
        }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:37,代码来源:Tap5050MenuBuilder.cs

示例6: DownloadAndSetImageView

        /// <summary>
        /// Downloads the and set image view. Downloads the Bitmap in a seperate task
        /// and updates the imageview in UI thread
        /// </summary>
        public void DownloadAndSetImageView( string url, ImageView imageView, int width, int height )
        {
            //If the imageview is being recycled and used for another photo, cancel the previous task
            //as that is not needed in the view anymore
            ImageViewTask imageTask = m_bitMapTasks.Find( task => task.View == imageView );
            if( imageTask != null )
            {
                imageTask.CancelToken.Cancel();
                imageView.SetImageResource( Resource.Drawable.Icon );
                lock( m_lockObject )
                {
                    m_bitMapTasks.Remove( imageTask );
                }
            }

            CancellationTokenSource cancelToken = new CancellationTokenSource();
            string url1 = url;
            ImageView imageView1 = imageView;
            Task bitmapTask = Task.Factory.StartNew( () =>
            {
                SetBitmap( url, width, height, imageView, cancelToken.Token );
            }, cancelToken.Token );
            imageTask = new ImageViewTask( url, imageView1, cancelToken );
            lock( m_lockObject )
            {
                m_bitMapTasks.Add( imageTask );
            }
        }
开发者ID:rohithc,项目名称:TestImageDownloader,代码行数:32,代码来源:ImageDownloader.cs

示例7: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

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

			// Get our button from the layout resource,
			// and attach an event to it
			GetButton = FindViewById<Button> (Resource.Id.GetButton);
			ResultTextView = FindViewById<TextView> (Resource.Id.ResultTextView);
			ResultEditText = FindViewById<EditText> (Resource.Id.ResultEditText);
			DownloadedImageView = FindViewById<ImageView> (Resource.Id.DownloadedImageView);

			GetButton.Click += async (sender, e) => {
				
				Task<int> sizeTask = DownloadHomePageAsync();

				ResultTextView.Text = "Loading...";
				ResultEditText.Text = "Loading...\n";

				DownloadedImageView.SetImageResource ( Android.Resource.Drawable.IcMenuGallery);

				var length = await sizeTask;

				ResultTextView.Text = "length:  " + length;

			};

		}
开发者ID:aragorn55,项目名称:ClassSampleCode,代码行数:30,代码来源:MainActivity.cs

示例8: OnCreate

        protected override void OnCreate(Bundle savedInstanceState) {
            base.OnCreate(savedInstanceState);
            
            var pos = 0;
            if (Intent.Extras != null)
                pos = Intent.Extras.GetInt("pos");

            var birds = Resources.GetStringArray(Resource.Array.birds);
            var imgs = Resources.ObtainTypedArray(Resource.Array.birds_img);
            var resId = imgs.GetResourceId(pos, -1);

            Title = birds[pos];
            Window.RequestFeature(WindowFeatures.ActionBarOverlay);
            var color = new ColorDrawable(Color.Black);
            color.SetAlpha(128);
            ActionBar.SetBackgroundDrawable(color);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            _handler = new Handler();

            var imageView = new ImageView(this);
            imageView.SetScaleType(ImageView.ScaleType.CenterInside);
            imageView.SetImageResource(resId);
            imageView.Click += (sender, args) =>
                {
                    ActionBar.Show();
                    HideActionBarDelayed(_handler);
                };
            SetContentView(imageView);
            Window.SetBackgroundDrawableResource(Android.Resource.Color.BackgroundDark);
        }
开发者ID:mamta-bisht,项目名称:SlidingMenuSharp,代码行数:30,代码来源:BirdActivity.cs

示例9: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            var actionBar = ((Activity)Context).ActionBar;
            LinearLayout layout = new LinearLayout(Context);
            layout.Orientation = Orientation.Horizontal;
            layout.WeightSum = 100;
            TextView title = new TextView(Context);
            title.Text = actionBar.Title;

            title.TextSize = 18;
            Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, "BTrafcBd.ttf");
            title.Typeface = font;

            LayoutParams textlp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            ImageView logo = new ImageView(Context);
            logo.SetImageResource(Resource.Drawable.Logo);
            LayoutParams imglp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            layout.AddView(title, textlp);
            layout.AddView(logo, imglp);
            actionBar.SetCustomView(layout, new ActionBar.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent));
            actionBar.SetDisplayOptions(ActionBarDisplayOptions.ShowCustom, ActionBarDisplayOptions.ShowCustom);
        }
开发者ID:mxmaa64,项目名称:Calender,代码行数:26,代码来源:MyContentPageRenderer.cs

示例10: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
			
			
			ImageView img = new ImageView(this);
			img.SetImageResource(Resource.Drawable.spadeicon);
			
            var root = new RootElement("Test Root Elem")
                           {
                               new Section("Test Header", "Test Footer")
                                   {
                                       new BooleanElement("Push my button", true),
                                       new BooleanElement("Push this too", false),
                                       new StringElement("Text label", "The Value"),
									   new BooleanElement("Push my button", true),
                                       new BooleanElement("Push this too", false),
                                   },
                               new Section("Part II")
                                   {
                                       new StringElement("This is the String Element", "The Value"),
                                       new CheckboxElement("Check this out", true),
                                       new ImageElement(img),
									   new HtmlElement("Go to Google.com","http://www.google.com")
                                   }
                           };

            var da = new DialogAdapter(this, root);

            var lv = new ListView(this) {Adapter = da};

            SetContentView(lv);
        }
开发者ID:xlvisuals,项目名称:MonoDroid.Dialog,代码行数:33,代码来源:Activity1.cs

示例11: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

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

			// Get our button from the layout resource,
			// and attach an event to it
			GetButton = FindViewById<Button> (Resource.Id.GetButton);
			ResultTextView = FindViewById<TextView> (Resource.Id.ResultTextView);
			ResultEditText = FindViewById<EditText> (Resource.Id.ResultEditText);
			DownloadedImageView = FindViewById<ImageView> (Resource.Id.DownloadedImageView);

			GetButton.Click += async (sender, e) => {

				Task<int> sizeTask = DownloadHomepageAsync();

				ResultTextView.Text = "loading...";
				ResultEditText.Text = "loading...\n";
				DownloadedImageView.SetImageResource (Android.Resource.Drawable.IcMenuGallery);

				// await! control returns to the caller
				var length = await sizeTask;

				// when the Task<int> returns, the value is available and we can display on the UI
				ResultTextView.Text = "Length: " + length ;

				// effectively returns void
			};

			// Alternate way to call
//			GetButton.Click += HandleClick;
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:34,代码来源:MainActivity.cs

示例12: SetCardImageWithoutAnimation

 public void SetCardImageWithoutAnimation(int drawableId)
 {
     currentDrawableId = drawableId;
     ImageView imageView = new ImageView(Context);
     imageView.SetImageResource(drawableId);
     AddView(imageView);
 }
开发者ID:TheJaniceTong,项目名称:Judo-Xamarin,代码行数:7,代码来源:CardImageView.cs

示例13: OnCreate

		//Metodo principal en el cual se creara el servicio y pintaremos nuestro imageview sobre la ventana
		public override void OnCreate ()
		{
			base.OnCreate ();
			//incializaremos en windowmanager obteniendo el servicio directo de la ventan del sistema y haremos
			//un casting de tipo JavaCast<IWindowManager>
			windowManager = GetSystemService ("window").JavaCast<IWindowManager> ();
			//inicializaremos nuestro imageview dandole los atributos de nuestra clase para que obtenga los metodos
			//de touch
			chatHead = new ImageView(this);
			//definimos la imagen del imageview
			chatHead.SetImageResource (Resource.Drawable.ic_launcher);
			//Asignamos el listener del touch nuestra clase del tipo View.IOnTouchListener
			chatHead.SetOnTouchListener (this);
			//instanciamos los parametros que necesitamos para poder tomar la pantalla y asi poder mostrar nuestro imageview
			param = new WindowManagerLayoutParams(
				WindowManagerLayoutParams.WrapContent,
				WindowManagerLayoutParams.WrapContent,
				WindowManagerTypes.Phone,
				WindowManagerFlags.NotFocusable,
				Format.Translucent);
			//Agregamos la propiedad de gravedad en la parte de arriba hacia la izquieda
			param.Gravity = GravityFlags.Top | GravityFlags.Left;
			//Asignamos la posicion X del imageview
			param.X = 0;
			//Asignamos la posicion Y del imageview
			param.Y = 100;
			//Agregamos una vista a la ventana del sistema con nuestro imageview y los parametros generados
			windowManager.AddView (chatHead, param);
		}
开发者ID:EnriqueProinfo,项目名称:Mono,代码行数:30,代码来源:ChatHeadService.cs

示例14: OnCreate

		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			// Create your application here
			SetContentView(Resource.Layout.Dictionary);

			mimgHome = FindViewById<ImageView>(Resource.Id.limgHome);
			mlstWords = FindViewById<ListView>(Resource.Id.llstWords);
			mpWord = MediaPlayer.Create(this, Resource.Raw.cebuano_woman);
			mimgHome.SetImageResource(Resource.Drawable.home);
			//srch = FindViewById<SearchView>(Resource.Id.search);

			try
			{
				var db = new SQLiteConnection(path);

				var words = db.Table<Dictionary>();
				foreach (var w in words)
				{
					mlistWords.Add(new DictWordModel { strCeb = w.CebuanoWord, strTag = w.TagalogWord });
				}
				mlstWords.Adapter = new DictWordAdapter(this, mlistWords);
				adapters = new ArrayAdapter<DictWordModel>(this, Android.Resource.Layout.SimpleListItem1, mlistWords);
			}
			catch (SQLiteException ex)
			{
				string m = ex.Message;
			}

			//lstWords.Adapter = new DictWordAdapter (this, mlistWords);
			mimgHome.Click += (object sender, EventArgs e) => StartActivity(typeof(actMenu));
			//mlstWords.ItemClick += (object sender, AdapterView .ItemClickEventArgs e) => mpWord.Start();
		}
开发者ID:jejeboom,项目名称:Cebuanizer,代码行数:34,代码来源:actDictionary.cs

示例15: OnCreate

        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                _task = Rep.DatabaseHelper.Tasks.Enumerator.Current;
                var category = Rep.DatabaseHelper.Tasks.GetCategory(_task.CategoryId);
                SetContentView(Resource.Layout.ImageCard);
                _image = FindViewById<ImageView>(Resource.Id.imageCardView);
                var imageIdentifier = this.Resources.GetIdentifier(category.Image, "drawable", this.PackageName);
                _image.SetImageResource(imageIdentifier);

                var text = FindViewById<TextView>(Resource.Id.textCard);
                text.SetTypeface(Rep.FontManager.Get(Font.BankirRetro), TypefaceStyle.Normal);
                text.Text = _task.TaskName;

                _contentFrameLayout = FindViewById(Resource.Id.contentFrameLayout);

                _contentFrameLayout.Click += ContentFrameLayoutOnClick;

            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class,"OnCreate", exception, false);
                base.OnBackPressed();
            }
        }
开发者ID:okrotowa,项目名称:Mosigra.Yorsh,代码行数:27,代码来源:ImageActivity.cs


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