多个日期选取器对话框 [英] Multiple Date-picker Dialog

查看:133
本文介绍了多个日期选取器对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个DatePicker的对话框,在其中显示在4个按钮点击我的活动课。现在,这些datePickerDialog我想使用相同的监听器。结果

  DatePickerDialog taxPickerDialog =新DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR),calendar.get(的Calendar.MONTH),calendar.get(Calendar.DATE) );
        taxPickerDialog.show();        DatePickerDialog fcPickerDialog =新DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR),calendar.get(的Calendar.MONTH),calendar.get(Calendar.DATE));
        fcPickerDialog.show();
        打破;        DatePickerDialog expiryPickerDialog =新DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR),calendar.get(的Calendar.MONTH),calendar.get(Calendar.DATE));
        expiryPickerDialog.show();
        DatePickerDialog permitPickerDialog =新DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR),calendar.get(的Calendar.MONTH),calendar.get(Calendar.DATE));
        permitPickerDialog.show();

现在我想用一个听众,但dnot知道如何实现这个???

  DatePickerDialog.OnDateSetListener dateSetListener =新DatePickerDialog.OnDateSetListener(){    @覆盖
    公共无效onDateSet(查看的DatePicker,年整型,诠释月,日整型){
    开关(????){????}
}
};


解决方案

我知道它的一晚答复,但我最近去通过相同的条件。因此,这里是我的答案,

 `DialogFragment.Show(FragmentManager经理,字符串标签))`

方法的片段本身设置标签。所以这个标签可以使用如下:

 片段dateTo = getActivity()getSupportFragmentManager()findFragmentByTag(dateTo)。;
            如果(dateTo!= NULL){
                //做一点事            }

一个用例是可以显示更多然后一个片段的活动,并确定片段,你可以找到与鉴于片段tag.If不是null ,宾果!

I have 4 DatePicker Dialog in my Activity Class which are shown on click of 4 buttons . Now for these datePickerDialog i want to use same listener .

        DatePickerDialog taxPickerDialog = new DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),calendar.get(Calendar.DATE));
        taxPickerDialog.show();

        DatePickerDialog fcPickerDialog = new DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),calendar.get(Calendar.DATE));
        fcPickerDialog.show();
        break;

        DatePickerDialog expiryPickerDialog = new DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),calendar.get(Calendar.DATE));
        expiryPickerDialog.show();


        DatePickerDialog permitPickerDialog = new DatePickerDialog(getCurrentContext(),dateSetListener,calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),calendar.get(Calendar.DATE));
        permitPickerDialog.show();

Now i want a use listener but dnot know how to implement this ???

DatePickerDialog.OnDateSetListener dateSetListener =new DatePickerDialog.OnDateSetListener() {

    @Override
    public void onDateSet(DatePicker view, int year, int month, int day) {
    switch(????){????}
}
};

解决方案

I know its a late reply but i went through with the same condition recently . So here is my answer ,

the

`DialogFragment.Show(FragmentManager manager, String tag))`

method is set tag for Fragment itself . so this tag can be use as follows :

Fragment dateTo=getActivity().getSupportFragmentManager().findFragmentByTag("dateTo");
            if(dateTo!=null){
                //do something

            } 

one use case is you can display more then one Fragment in a activity and to identify the fragment you can find that fragment with the given tag.If it is not null, bingo!!!

这篇关于多个日期选取器对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆