Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 重新启动日历_Android_Android Fragments_Android Calendar - Fatal编程技术网

Android 重新启动日历

Android 重新启动日历,android,android-fragments,android-calendar,Android,Android Fragments,Android Calendar,我把这个网站的日历 成功装入碎片 但在我替换了碎片之后 所有日历都将变为空白日历 我必须被替换以正确显示月份 但我更改指定日期的颜色失败 和调用格式数据将导致nullpointerexception 我该怎么修理 活动 public class index_Activity extends FragmentActivity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(save

我把这个网站的日历

成功装入碎片

但在我替换了碎片之后

所有日历都将变为空白日历

我必须被替换以正确显示月份

但我更改指定日期的颜色失败

和调用格式数据将导致nullpointerexception

我该怎么修理

活动

public class index_Activity extends FragmentActivity{
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_main);
            fm2 = getSupportFragmentManager();
            DSE2 = fm2.beginTransaction();
            e_f=fm2.findFragmentById(R.id.main_frame_e);

            mRadioButton1.toggle();


        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            Log.i("zj", "checkedid="+checkedId);
            fm2 = getSupportFragmentManager();
            DSE2 = fm2.beginTransaction();
            DF2 = fm2.findFragmentById(R.id.main_frame);

            if (checkedId == R.id.btn1) {

                if (DF2 == null ) {
                    fg_a usermune = new fg_a("nono");
                    DSE2.add(R.id.main_frame,usermune);
                    DSE2.commit();
                } else if (DF2 != null) {
                    DSE2.remove(DF2);
                    fg_a usermune = new fg_a("nono");
                    DSE2.add(R.id.main_frame,usermune);
                    DSE2.commit();
                }

            }else if (checkedId == R.id.btn2) {
                if (DF2== null ) {
                    fg_b usermune = new fg_b("nono");
                    DSE2.add(R.id.main_frame, usermune);
                    DSE2.commit();
                } else if (DF2 != null ) {
                    DSE2.remove(DF2);
                    fg_b usermune = new fg_b("nono");
                    DSE2.add(R.id.main_frame,usermune);
                    DSE2.commit();
                }

            }else if (checkedId == R.id.btn3) {
    ///////////////////Open the calendar//
                if (DF2== null ) {
                    fg_c usermune = new fg_c("nono");
                    DSE2.add(R.id.main_frame, usermune);
                    DSE2.commit();
                } else if (DF2 != null ) {
                    DSE2.remove(DF2);
                    fg_c usermune = new fg_c("nono");
                    DSE2.add(R.id.main_frame, usermune);
                    DSE2.commit();
                }
    ////////////////////////////////////////

            }else if (checkedId == R.id.btn4) {
                page[i]=4;
                i++;
         startActivity(fg_d_link);


                }else if (checkedId == R.id.btn5) {
                touch=4;
                page[i]=5;
                i++;
                if (DF2== null ) {
                    fg_e usermune = new fg_e("nono");
                    DSE2.add(R.id.main_frame, usermune);
                    DSE2.commit();
                } else if (DF2 != null ) {
                    DSE2.remove(DF2);
                    fg_e usermune = new fg_e("nono");
                    DSE2.add(R.id.main_frame, usermune);
                    DSE2.commit();
                }

            }

            mCurrentCheckedRadioLeft = getCurrentCheckedRadioLeft();

        }
日历框架:

public class fg_c extends Fragment {
    SimpleDateFormat formatter;
    Date[] setday;
    int t;
    FragmentManager fm;
    FragmentTransaction DSE2;
    Fragment DF2;
    private DBOpenHelper dbHelper;
    private ArrayList<Site> sites;
    private final String title1;
    int page_open=0;
    public fg_c(String string) {
        this.title1 = string;
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View fragmentView = inflater.inflate(R.layout.caldroid_main,container, false);

   formatter = new SimpleDateFormat("dd MMM yyyy");

        // Setup caldroid fragment
        // **** If you want normal CaldroidFragment, use below line ****
        caldroidFragment = new CaldroidFragment();







        // //////////////////////////////////////////////////////////////////////
        // **** This is to show customized fragment. If you want customized
        // version, uncomment below line ****
        // caldroidFragment = new CaldroidSampleCustomFragment();

        // Setup arguments

        // If Activity is created after rotation
        if (savedInstanceState != null) {
            caldroidFragment.restoreStatesFromKey(savedInstanceState,
                    "CALDROID_SAVED_STATE");
        }
        // If activity is created from fresh
        else {
            Bundle args = new Bundle();
            Calendar cal = Calendar.getInstance();
            args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
            args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
            args.putBoolean(CaldroidFragment.ENABLE_SWIPE, true);
            args.putBoolean(CaldroidFragment.SIX_WEEKS_IN_CALENDAR, true);
            caldroidFragment.setArguments(args);
        }

        setCustomResourceForDates();

        // Attach to the activity
        android.support.v4.app.FragmentTransaction t =      getActivity().getSupportFragmentManager().beginTransaction();
        t.replace(R.id.calendar1, caldroidFragment);
        t.commit();

        // Setup listener
        final CaldroidListener listener = new CaldroidListener() {

            @Override
            public void onSelectDate(Date date, View view) {
//nullpointerexception
                Toast.makeText(getActivity(), formatter.format(date),
                        Toast.LENGTH_SHORT).show();
//

            }

            @Override
            public void onChangeMonth(int month, int year) {
                String text = "month: " + month + " year: " + year;
                Toast.makeText(getActivity(), text,
                        Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onLongClickDate(Date date, View view) {
                Toast.makeText(getActivity(),
                        "Long click " + formatter.format(date),
                        Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onCaldroidViewCreated() {
                if (caldroidFragment.getLeftArrowButton() != null) {
                    Toast.makeText(getActivity(),
                            "Caldroid view is created", Toast.LENGTH_SHORT)
                            .show();
                }
            }


        };

        // Setup Caldroid
        caldroidFragment.setCaldroidListener(listener);

        final TextView textView = (TextView) fragmentView.findViewById(R.id.textview);
        return fragmentView;
    }
    private boolean undo = false;
    private CaldroidFragment caldroidFragment;
    private CaldroidFragment dialogCaldroidFragment;

    private void setCustomResourceForDates() {
        Calendar cal = Calendar.getInstance();

        for(int i=0;i<t;i++){
            cal.set(Integer.valueOf(year[i]).intValue(),Integer.valueOf(mon[i]).intValue(),Integer.valueOf(day[i]).intValue() , 0, 0, 0);
            setday[i] = cal.getTime();
        }
            for (int j=0;j<t;j++){
            caldroidFragment.setBackgroundResourceForDate(R.color.green,
                    setday[j]);
            caldroidFragment.setTextColorForDate(R.color.white, setday[j]);
            }
        }
    }


    @Override
    public void onSaveInstanceState(Bundle outState) {
        // TODO Auto-generated method stub
        super.onSaveInstanceState(outState);

        if (caldroidFragment != null) {
            caldroidFragment.saveStatesToKey(outState, "CALDROID_SAVED_STATE");
        }

        if (dialogCaldroidFragment != null) {
            dialogCaldroidFragment.saveStatesToKey(outState,
                    "DIALOG_CALDROID_SAVED_STATE");
        }
    }
公共类fg_c扩展片段{
SimpleDataFormat格式化程序;
日期[]设定日;
int t;
碎片管理器fm;
碎片事务DSE2;
片段DF2;
私有DBOpenHelper-dbHelper;
私人ArrayList站点;
私人最终字符串标题1;
int page_open=0;
公共fg_c(字符串){
this.title1=字符串;
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
视图碎片视图=充气机。充气(右布局。caldroid\u主容器,假);
格式化程序=新的SimpleDataFormat(“dd MMM yyyy”);
//设置caldroid片段
//****如果您想要普通CaldroidFragment,请使用下面的行****
caldroidFragment=新的caldroidFragment();
// //////////////////////////////////////////////////////////////////////
//****这是为了显示自定义片段。如果要自定义
//版本,在第行下方取消注释****
//caldroidFragment=新的CaldroidSampleCustomFragment();
//设置参数
//如果活动是在旋转后创建的
如果(savedInstanceState!=null){
caldroidFragment.restoreStatesFromKey(savedInstanceState,
“卡尔德罗德救了州”);
}
//如果活动是从新创建的
否则{
Bundle args=新Bundle();
Calendar cal=Calendar.getInstance();
args.putInt(CaldroidFragment.MONTH,cal.get(Calendar.MONTH)+1);
args.putInt(CaldroidFragment.YEAR,cal.get(Calendar.YEAR));
args.putBoolean(CaldroidFragment.ENABLE_SWIPE,true);
args.putBoolean(日历中的CaldroidFragment.SIX_WEEKS_,true);
caldroidFragment.setArguments(args);
}
setCustomResourceForDates();
//参加活动
android.support.v4.app.FragmentTransaction t=getActivity().getSupportFragmentManager().beginTransaction();
t、 更换(R.id.calendar1,caldroidFragment);
t、 提交();
//设置侦听器
最终CaldroidListener侦听器=新的CaldroidListener(){
@凌驾
在选择日期(日期、视图)上的公共无效{
//nullpointerexception
Toast.makeText(getActivity(),formatter.format(date),
吐司。长度(短)。show();
//
}
@凌驾
变更月公共作废(整数月、整数年){
String text=“月:+月+”年:+年;
Toast.makeText(getActivity(),text,
吐司。长度(短)。show();
}
@凌驾
仅限长点击日期的公共作废(日期,查看){
Toast.makeText(getActivity(),
“长按”+格式化程序。格式化(日期),
吐司。长度(短)。show();
}
@凌驾
公共void onCaldroidViewCreated(){
如果(caldroidFragment.getLeftArrowButton()!=null){
Toast.makeText(getActivity(),
“Caldroid视图已创建”,Toast.LENGTH_SHORT)
.show();
}
}
};
//设置Caldroid
caldroidFragment.setCaldroidListener(侦听器);
final TextView TextView=(TextView)fragmentView.findViewById(R.id.TextView);
返回碎片视图;
}
私有布尔撤消=false;
私人CaldroidFragment CaldroidFragment;
专用CaldroidFragment对话框CaldroidFragment;
私有void setCustomResourceForDates(){
Calendar cal=Calendar.getInstance();

对于(inti=0;i我重写了库的一部分 这导致了一个错误 因为我的jar不支持getChildFragmentManager() 我重写了getFragmentManager() 由以下原因引起的错误