我正在构建一个
Android应用程序,我需要创建一个简单的String项列表,然后我将为列表中的每个项添加一个特定的控件.
这是我要创建的列表:
List projects = new List(); // How?
我正在尝试的代码:
String projects = new string[] { "hey","yo","app","xamarin","c","xaml" };
我需要计算这些项目,如下所示:
int amount = projects.Count(); // Can I do this?
然后为列表中的每个项添加控件
// Add the tiles, one by one
for (int i = 0; i < amount; i++)
{
// Inflate the tile
var tile = LayoutInflater.Inflate (Resource.Layout.Tile, null);
// Set its attributes
tile.FindViewById (Resource.Id.projectName).Text = currentProject;
// Add the tile
projectScrollView.AddView (tile);
}
从SharedPreferences中检索“currentProject”字符串,还没有那么远