android - 处理颤动中动态可扩展列表的项目点击
问题描述
我在动态列表中有动态列表,我需要用它们的属性保存选项。我尝试了很多方法来显示每个选项的属性下拉列表,但DropDownMenuitem
Widgets 不处理稳定版本的 Flutter 中的动态列表,因此我必须为此目的使用 Expandable List。当我选择一个选项的属性时,如何在标题中反映对特定选项的选择,或者如何保存对动态属性的选择
这就是我建立我的清单的方式
ListView.builder(
shrinkWrap: true,
itemCount: opAtrrList.length>0?opAtrrList.length:0,
itemBuilder: (context, i) {
return ExpansionTile(
title:optionTitle(width,height,opAtrrList[i].groupname,selectedAttr),
children: <Widget>[
new Column(
children: _buildExpandableContent(opAtrrList[i]),
),
],
);
},
),
这是我的可扩展项目Attribute selectedAttr;
_buildExpandableContent(OptionAttribute oa) {
List<Widget> columnContent = [];
for(int i=0;i<oa.attrlist.length;i++){
columnContent.add(
new ListTile(
onTap: (){
setState(() {
selectedAttr=oa.attrlist[i];
});
},
title: new Text(oa.attrlist[i].attributename, style: TextStyle(fontFamily: 'medium',color: MyColors.colorPrimaryDark)),
),
);
}
return columnContent;
}
请看下面的gif。
解决方案
推荐阅读
- python - 如何在 conv2d 层中使用 PReLU
- r - 在R中用最常见的值替换值
- docker - 码头集装箱 ID 未显示
- typescript - 如何为导出函数的模块创建声明文件?
- api - 得到那个错误“类型'String'不是'index'类型'int'的子类型”颤动
- python - 即使在 python 中调整大小后,如何从静态图像中获取特定的极值点数?
- html - 如何在tailwindcss中的浮动图像旁边居中文本
- c# - 以 void* 作为参数调用 MethodInfo
- reactjs - useReducer 用于购物车而不使用上下文
- javascript - 有没有办法在Angular中为firebase添加基于环境的配置