java - 显示 DialogFragment 活动时出错
问题描述
使用以下代码,我收到此错误:
错误:';' 预期 dialogFragment.show((Activity) _context).getSupportFragmentManager(), "Dialog"));
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = (TextView) convertView.findViewById(R.id.lblListItem);
Button btnListChild = (Button) convertView.findViewById(R.id.btn);
btnListChild.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CustomDialogClass dialogFragment = new CustomDialogClass();
dialogFragment.show((Activity) _context).getSupportFragmentManager(), "Dialog"));
}
});
txtListChild.setText(childText);
return convertView;
}
解决方案
更改 dialogFragment.show((Activity) _context).getSupportFragmentManager(), "Dialog")); 到 dialogFragment.show((Activity) _context.getSupportFragmentManager(), "Dialog");
推荐阅读
- python-3.x - Python 3 中使用二分搜索的立方根:-1 到 0 中的数字
- javascript - 如何在 Javascript 中导出 GeoJSON
- android - Android - 即使将 kotlin 用作语言,Java 包名称也不会更改为 Kotlin
- java - TestNG 并行执行 - 并行类的问题
- javascript - 评估混淆的 JavaScript 变量声明
- reactjs - 如何在 react-highlight-words 中使用 dangerouslySetInnerHTML
- c - 从 lcov 的覆盖率报告中排除文件
- java - Java XML Parse - 删除第一个标签
- html - 背景颜色不适用于 HTML 元素?
- orm - Sequelize - 在父范围内排除默认子关系