總網頁瀏覽量

關於我自己

我的相片
人生的必修課是接受無常,人生的選修課是放下執著。

2014年6月29日 星期日

關掉指定Dialog

public class InfoDialog extends DialogFragment{
    Context context;
    public static final String BUNDLE_KEY_PRIZE = "bundle_key_prize";
    static Dialog dialog;
    public InfoDialog(Context context) {
        this.context = context;
    }

    InfoDialog dialog = new InfoDialog(context);
    Bundle args = new Bundle();
    args.putInt(InfoDialog.BUNDLE_KEY_PRIZE, -1);   
    dialog.setArguments(args);
    dialog.show();

}

若在InfoDialog這一層, 可以用dismiss()來關掉dialog
若另起別層(ListView或GridView之類), 則要用InfoDialog.dialog.dismiss()

沒有留言:

張貼留言