c# – 在Android Xamarin中创建列表
发布时间:2020-12-16 01:59:59 所属栏目:百科 来源:网络整理
导读:我正在构建一个 Android应用程序,我需要创建一个简单的String项列表,然后我将为列表中的每个项添加一个特定的控件. 这是我要创建的列表: ListString projects = new ListString(); // How? 我正在尝试的代码: String projects = new string[] { "hey","yo"
我正在构建一个
Android应用程序,我需要创建一个简单的String项列表,然后我将为列表中的每个项添加一个特定的控件.
这是我要创建的列表: List<String> projects = new List<String>(); // 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<TextView> (Resource.Id.projectName).Text = currentProject; // Add the tile projectScrollView.AddView (tile); } 从SharedPreferences中检索“currentProject”字符串,还没有那么远 解决方法var projects = new List<String>() { "hey","xaml" }; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 我一直得到发送到我的服务器的QUIT和CONN
- u-boot-2011.03移植系列专题汇总
- cocos2d-x3.2与服务端框架Firefly的网络编程(初级网络通讯
- c# – 强制循环迭代
- 设置、读取联络人头像 ---- save UIImage to ABAddressBook
- 使用React创建交互式SVG组件
- Using Flashback Drop and Managing the Recycle Bin
- OpenFlashChart2的使用
- 「React 16」为 Luy 实现 React Fiber 架构
- react中constructor和super()以及super(props)的区别。