0

我正在尝试创建一个DialogFragment允许您输入四个字段的类,然后单击“完成”按钮。单击按钮后,DialogFragment应更改某些文本值,然后终止返回主屏幕。

到目前为止,我让它做我想做的一切,除了终止。对话框将所选内容更改TextView为“你好”,然后一直徘徊。

谁能告诉我如何让它消失?谢谢!

public class TeamFragment extends DialogFragment {
    TextView team1, team2, score1, score2;

    public TeamFragment(View t1, View t2, View s1, View s2) {
        team1=(TextView) t1;
        team2=(TextView) t2;
        score1=(TextView) s1;
        score2=(TextView) s2;
    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.team_score_layout, container);
        //mEditText = (EditText) view.findViewById(R.id.txt_your_name);
        getDialog().setTitle("Enter Team Name");
        Button b = (Button) view.findViewById(R.id.teamButton);

        b.setOnClickListener(new OnClickListener() {
          public void onClick(View v) {
            team1.setText("hello");

          }
        });
        return view;
    }
}
4

1 回答 1

1

您可以使用以下方法关闭DialogFragment

dismiss()
于 2013-04-23T19:22:06.450 回答