0

我无法从 DialogFragment 课程中收听 RadioGroup。我没有收到任何错误,但日志没有显示任何内容。请帮我...

public class SimpleDialog extends DialogFragment{

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());


    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.radio, null);

    builder.setTitle(R.string.dialog_name)
            .setView(inflater.inflate(R.layout.radio, null))
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
               }
           });


    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup);
    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() 
    {
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            Log.v("Dialog", "checked");
        }
    });

    return builder.create();
}

}

4

1 回答 1

0

我刚刚想通了,我必须传递给 builder.setView(view)

于 2013-06-03T12:19:06.817 回答