首页 > 解决方案 > 显示 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;
}

标签: javaandroid

解决方案


更改 dialogFragment.show((Activity) _context).getSupportFragmentManager(), "Dialog")); 到 dialogFragment.show((Activity) _context.getSupportFragmentManager(), "Dialog");


推荐阅读