2015-03-25 55 views
0

我在Youtube上發現了這個很好的教程:https://www.youtube.com/watch?v=WRANgDgM2Zg這正是我想要做的。 無法找到任何Xamarin,所以我決定嘗試Xamarin如何用Xamarin中的文本和圖像創建ListView?

我創建了我的用戶配置文件就像這樣;

using System;

namespace ListViewTest 
{ 
    public class UserProfile 
    { 
     private string name; 
     private int ProfileID; 
     private int ImageID; 

     public UserProfile (string name, int ProfileID, int ImageID) 
     { 
      this.name = name; 
      this.ProfileID = ProfileID; 
      this.ImageID = ImageID; 
     } 

     public string GetName(){ 
      return name; 
     } 

     public int GetProfileID(){ 
      return ProfileID; 
     } 

     public int GetImageID(){ 
      return ImageID; 
     } 

    } 
} 

但是,試圖打造這樣它的一個實例時:

List<UserProfile> myProfiles = new ArrayList<UserProfile>(); 

它說:「該類型或命名空間名稱的ArrayList找不到是否缺少using指令或程序集引用?」此消息出現在ArrayList

我不確定缺少什麼?

+0

您已經添加'使用path.to.UserProfile'在你正在創建'UserProfile'的實例嗎? – Apurva 2015-03-25 07:29:08

回答

0

在C#中沒有什麼像ArrayList <>。意味着ArrayList沒有通用的實現。因爲在ArrayList中可以存儲任何類型的對象,所以沒有提供它的通用含義。

在這種情況下,你可以使用

List<UserProfile> myProfiles = new List<UserProfile>(); 

同時建議你,你可以改變你的get方法類似性質:

private string name; 
public string Name 
{ 
    get { return name; } 
} 
相關問題