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


C# ImageView.SetImageURI方法代码示例

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


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

示例1: DownloadHistory

		public 	async void DownloadHistory ( ImageView imageView,string url,ProgressBar Pbar =null)
		{

			if (string.IsNullOrEmpty(url))
				return;


			try {	

				int index = url.LastIndexOf ("/");
				string localFilename = url.Substring (index + 1);
				var webClient = new WebClient ();
				var uri = new Uri (url);
				webClient.DownloadProgressChanged +=   (sender, e) => {if(Pbar!=null)  Pbar.Progress=e.ProgressPercentage; };


				documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);	

				localPath = System.IO.Path.Combine (documentsPath, localFilename);
				var localImage = new Java.IO.File (localPath);

				if (localImage.Exists ()) {

					var imgUri=Android.Net.Uri.Parse("file:"+localPath);
					imageView.SetImageURI(imgUri);

				} else {

					byte[] bytes = null;		
					bytes = await webClient.DownloadDataTaskAsync (uri);

					FileStream fs = new FileStream (localPath, FileMode.Create);
					await fs.WriteAsync (bytes, 0, bytes.Length);
					fs.Close ();	

					var imgUri=Android.Net.Uri.Parse("file:"+localPath);
					imageView.SetImageURI(imgUri);

//					teamBitmap = await BitmapFactory.DecodeByteArrayAsync (bytes, 0, bytes.Length);
//					imageView.SetImageBitmap (teamBitmap);

				}

			



			} catch (TaskCanceledException) {

				return;
			} catch (Exception) {
				return;
			}



		}
开发者ID:jhondiaz,项目名称:Poraka,代码行数:57,代码来源:DownloadAsync.cs

示例2: OnViewCreated

        public override void OnViewCreated(View view, Bundle bundle)
        {
            base.OnViewCreated(view, bundle);

            imageView = view.FindViewById<ImageView>(Resource.Id.describe_image);
            instructionView = view.FindViewById<TextView>(Resource.Id.describe_text);

            if (data.PromptCol == null || data.PromptCol.Prompts.Length == 0)
            {
                instructionView.Text = "Please describe the image.";
            }
            else
            {
                instructionView.Text = data.PromptCol.Prompts[instructionIndex].Value;
                if (instructionIndex + 1 == data.PromptCol.Prompts.Length) finished = true;
            }

            while (runOnceCreated.Count > 0)
            {
                runOnceCreated.Pop().Invoke();
            }

            finishedCreating = true;

            try
            {
                imageView.SetImageURI(Android.Net.Uri.FromFile(new Java.IO.File(data.Image)));
            }
            catch(Exception e)
            {
                AppData.Io.PrintToConsole(e.Message);
                (Activity as AssessmentActivity).SelfDestruct();
            }
        }
开发者ID:GSDan,项目名称:Speeching_Client,代码行数:34,代码来源:AssessmentImgDescFragment.cs

示例3: OnCreate

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

            // Create your application here

            SetContentView (Resource.Layout.display_layout);

            delete_Btn = FindViewById<Button> (Resource.Id.delete_btn);
            delete_Btn.SetBackgroundColor (Android.Graphics.Color.Red);

            confirm_Btn = FindViewById<Button> (Resource.Id.confirm_btn);
            confirm_Btn.SetBackgroundColor (Android.Graphics.Color.Green);

            imageView = FindViewById <ImageView> (Resource.Id.image);
            var position = Intent.GetStringExtra ("pos");
            var source = Intent.GetStringExtra ("source");

            Android.Net.Uri uri = Android.Net.Uri.Parse (source);
            imageView.SetImageURI (uri);

            confirm_Btn.Click += (object sender, EventArgs e) => {
                Finish ();
            };

            delete_Btn.Click += (object sender, EventArgs e) => {

                //MessageActivity._temp_IMG_List.RemoveAt(int.Parse(position));

                var intent = new Intent();
                intent.PutExtra("delete",position);
                SetResult(Result.Ok,intent);
                Finish ();
            };
        }
开发者ID:WenF,项目名称:SSCA_FlagThis,代码行数:35,代码来源:DisplayPhotoActivity.cs

示例4: OnActivityResult

        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == Result.Ok)
            {
                _imageSection =
                    FindViewById<ImageView>(Resource.Id.myImageView);
                _imageSection.SetImageURI(data.Data);

                
                byte[] bytes;
                using (var imageData = _imageSection.AsJPEG())
                {
                    bytes = new byte[imageData.Length];
                    Marshal.Copy(imageData.Bytes, bytes, 0, Convert.ToInt32(imageData.Length));
                }

                //        await _uploader.UploadPhoto(bytes, "jpg");

            }
        }
开发者ID:jm991,项目名称:RealTimeGallery,代码行数:22,代码来源:MainActivity.cs

示例5: InitializeUi

		private void InitializeUi()
		{
			if (IsUiInitialized) return;

			_statusText = FindViewById<TextView>(Resource.Id.StatusText);

			_overlay = FindViewById<RelativeLayout>(Resource.Id.Overlay);

			_classText = FindViewById<EditText>(Resource.Id.ClassTextView);
			if (CurrentData.Class != string.Empty) _classText.Text = CurrentData.Class;

			_tagsText = FindViewById<EditText>(Resource.Id.TagsTextView);
			if (CurrentData.Tags != string.Empty) _tagsText.Text = CurrentData.Tags;

			_notesText = FindViewById<EditText>(Resource.Id.NotesTextView);
			if (CurrentData.Notes != string.Empty) _notesText.Text = CurrentData.Notes;

			_picturePreview = FindViewById<ImageView>(Resource.Id.PicturePreviewView);
			if (CurrentData.PicturePath != string.Empty) _picturePreview.SetImageURI(Uri.Parse(CurrentData.PicturePath));
			_picturePreview.Enabled = false;	//TODO remove when picture access is fixed

			_classHelp = FindViewById<ImageButton>(Resource.Id.ClassHelp);

			_tagsHelp = FindViewById<ImageButton>(Resource.Id.TagsHelp);

			_pictureHelp = FindViewById<ImageButton>(Resource.Id.PictureHelp);

			_notesHelp = FindViewById<ImageButton>(Resource.Id.NotesHelp);

			_cancelButton = FindViewById<Button>(Resource.Id.CancelButton);

			_sendButton = FindViewById<Button>(Resource.Id.SendButton);
			_sendButton.Enabled = false;

			IsUiInitialized = true;
		}
开发者ID:mdanz92,项目名称:teco.SkillStore,代码行数:36,代码来源:FeedbackActivity.cs

示例6: AddImage

        private void AddImage(string path)
        {
            LinearLayout llNewImage = new LinearLayout(this);
            llNewImage.LayoutParameters = new ViewGroup.LayoutParams(
                LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
            var p = Constants.PreviewCard.BorderSize;
            llNewImage.SetPadding(p, p, p, p);
            var img = new ImageView(this);
            img.LayoutParameters = new LinearLayout.LayoutParams(
                Constants.PreviewCard.ImageWidth, Constants.PreviewCard.ImageHeight);
            try
            {
                img.SetImageURI(Android.Net.Uri.Parse(path));
            } catch(Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Short).Show();
                img.SetImageResource(Resource.Drawable.ErrorImage);
            }
            llNewImage.AddView(img);
            llImages.AddView(llNewImage);

            ImageData id = new ImageData();
            id.ImageFile = path;
            id.layoutWithImage = llNewImage;
            id.Selected = false;
            images.Add(id);
            CheckShowNoImage();
            SetButtonsEnabled();

            img.Click += (o, s) => img_Click(id);
            /*switch (num)
            {
                case 0:
                    ivFore.SetImageURI(uri);
                    return;
                case 1:
                    ivBack.SetImageURI(uri);
                    return;
                default:
                    break;
            }*/
        }
开发者ID:Lissov,项目名称:BonusCards,代码行数:42,代码来源:EditCardActivity.cs


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