2017-09-23 1 views
0

Je développe une application Android de xamarin où j'ai mis en place une liste. donc j'ai besoin d'afficher cette image dans la liste, donc comment afficher l'image dans imageview en utilisant le chemin.DIsplay image dans l'imageview du stockage local

Je ne reçois pas comment afficher l'image du chemin du fichier dans xamarin.android

Voici mon CustomAdaptor

internal class MyCustomListAdapter : BaseAdapter 
{ 
    private List<AlbumTable> albm; 
    private LayoutInflater mInflater; 
    Context c; 
    Dialog dialog; 
    public MyCustomListAdapter(Context c,List<AlbumTable> albm) 
    { 
     this.albm = albm; 
     this.c = c; 
     mInflater = (LayoutInflater)c.GetSystemService(Context.LayoutInflaterService); 

    } 

    public override int Count 
    { 

     get 
     { 
      return albm.Count(); 
     } 
    } 

    public override Java.Lang.Object GetItem(int position) 
    { 
     return null; 
    } 

    public override long GetItemId(int position) 
    { 
     return long.Parse(albm[position].Id); 
    } 

    public override View GetView(int position, View view, ViewGroup parent) 
    { 
     Button btnDelete; 

     ViewHolder1 holder = null; 
     if (view == null) 
     { 
      view = mInflater.Inflate(Resource.Layout.inflate_album, null); 
      holder = new ViewHolder1(); 
      holder.coverp = view.FindViewById<ImageView>(Resource.Id.sliderviewpager); 
      btnDelete = view.FindViewById<Button>(Resource.Id.share_album); 
      btnDelete.Focusable = false; 
      btnDelete.FocusableInTouchMode = false; 
      btnDelete.Clickable = true; 
      btnDelete.Click += (object sender, EventArgs e) => 
      { 

       Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(c); 
       alert.SetTitle("Delete Album"); 
       alert.SetMessage("Are you really wnt to delete the Album"); 
       alert.SetCancelable(false); 
       alert.SetPositiveButton("Yes", delegate { 
        DatabaseHelper db = new DatabaseHelper(); 
        bool aa=db.DeleteFromTable(albm[position]); 

        if (aa) 
        { 
         Toast.MakeText(c, "Album Deleted Successfully", ToastLength.Short).Show(); 
        } 
       }); 
       alert.SetNegativeButton("No", delegate { 
        if (dialog.IsShowing) 
         dialog.Dismiss(); 
       }); 
       dialog = alert.Create(); 
       dialog.Show(); 

      }; 
     } 
     else 
     { 
      btnDelete = view.FindViewById<Button>(Resource.Id.share_album); 
      holder = view.Tag as ViewHolder1; 
      btnDelete.Tag = position; 

     } 

     return view; 
    } 

et mes méthodes setter getter sont les suivantes

class AlbumTable 
{ 

    [PrimaryKey] 
    public string Id { get; set; } 

    public string ZipFillPath { get; set; } 

    public string CoverPhotoPath { get; set; } 

    public string AlbumKey { get; set; } 

    public string NoOfPages { get; set; } 

    public string Email { get; set; } 

    public string LastName { get; set; } 

    public string FirstName { get; set; } 

    public string City { get; set; } 

    public string Address1 { get; set; } 

    public string ZipPostalCode { get; set; } 

    public string PhoneNumber { get; set; } 

}

Comment afficher l'image dans imageview en utilisant le chemin.

Répondre

0

Comment afficher l'image en mode image à l'aide du chemin.

Il y a une bibliothèque tierce qui implémente cette fonctionnalité très bien comme Picasso ou Glide.

Pour Picasso, il existe un document officiel qui montre comment l'utiliser dans le projet Xamarin.Android: Binding a .JAR.

Ensuite, vous pouvez coder par exemple comme ceci:

Picasso.With(this).Load(imageUrl).Into(imageView);