如何用Xamarin中的文本和图像创建ListView?
问题描述:
我在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
我不确定缺少什么?
答
在C#中没有什么像ArrayList <>。意味着ArrayList没有通用的实现。因为在ArrayList中可以存储任何类型的对象,所以没有提供它的通用含义。
在这种情况下,你可以使用
List<UserProfile> myProfiles = new List<UserProfile>();
同时建议你,你可以改变你的get方法类似性质:
private string name;
public string Name
{
get { return name; }
}
您已经添加'使用path.to.UserProfile'在你正在创建'UserProfile'的实例吗? – Apurva 2015-03-25 07:29:08