每次请求都重置一次fragment

    List boothCounts = t.getList(Res_BoothCount.class);
                mRgNavi.removeAllViews();
                for (BaseFragment fragment : mAllFrags) {
                    removeFragment(fragment);
                }
                mAllFrags.clear();
                for (Res_BoothCount boothCount : boothCounts) {
                    MLogUtil.e("boothCount " + boothCount.getBoothId());
                    TanweiFragment1 fragment1 = new TanweiFragment1();
                    mAllFrags.add(fragment1);
                    tanweiOrder = boothCount.getOrderCount();
                    tanweiName = boothCount.getBoothName();
                    showFrag(fragment1);
                    tempButton = new RadioButton(mBaseActivity);
                    tempButton.setBackgroundResource(R.drawable.tanwei1_selector); // 设置RadioButton的背景图片
                    tempButton.setButtonDrawable(null); // 设置按钮的样式
                    // tempButton.setPadding(80, 0, 0, 0); // 设置文字距离按钮四周的距离

                    tempButton.setText("    " + tanweiName + " (" + tanweiOrder + "单" + ")");

                    mRgNavi.addView(tempButton, LinearLayout.LayoutParams.WRAP_CONTENT,
                            LinearLayout.LayoutParams.WRAP_CONTENT);
                    Log.e("1", "run:--------->tanweiOrder: " + tanweiOrder);
                    // // mTvTanwei1Num.setText(boothCount.getOrderCount()+"");
                    if (boothCount.getBoothId().equals("370203010001")) {
                        // radioGroup.check(radioButton.getId());
                        tempButton.setChecked(true);
                        // new TanweiFragment1();
                        Log.e("1", "run:--------->66tanweiOrder: " + tanweiOrder);
                        Log.e("1", "run:--------->3333333 ");
                        // showFrag(mTanweiFragment1);
                    }
                }
private void orderPageInit1(String regCode, String startTime, String endTime) {
        // TODO Auto-generated method stub
        ApiService.orderPageInit(regCode, startTime, endTime, new BaseCallBack() {
            @Override
            public void onSuccess(Res_BaseBean t) {
                // TODO Auto-generated method stub
                List boothCounts = t.getList(Res_BoothCount.class);
                mRgNavi.removeAllViews();
                for (BaseFragment fragment : mAllFrags) {
                    removeFragment(fragment);
                }
                mAllFrags.clear();
                for (Res_BoothCount boothCount : boothCounts) {
                    MLogUtil.e("boothCount " + boothCount.getBoothId());
                    TanweiFragment1 fragment1 = new TanweiFragment1();
                    mAllFrags.add(fragment1);
                    tanweiOrder = boothCount.getOrderCount();
                    tanweiName = boothCount.getBoothName();
                    showFrag(fragment1);
                    tempButton = new RadioButton(mBaseActivity);
                    tempButton.setBackgroundResource(R.drawable.tanwei1_selector); // 设置RadioButton的背景图片
                    tempButton.setButtonDrawable(null); // 设置按钮的样式
                    // tempButton.setPadding(80, 0, 0, 0); // 设置文字距离按钮四周的距离

                    tempButton.setText("    " + tanweiName + " (" + tanweiOrder + "单" + ")");

                    mRgNavi.addView(tempButton, LinearLayout.LayoutParams.WRAP_CONTENT,
                            LinearLayout.LayoutParams.WRAP_CONTENT);
                    Log.e("1", "run:--------->tanweiOrder: " + tanweiOrder);
                    // // mTvTanwei1Num.setText(boothCount.getOrderCount()+"");
                    if (boothCount.getBoothId().equals("370203010001")) {
                        // radioGroup.check(radioButton.getId());
                        tempButton.setChecked(true);
                        // new TanweiFragment1();
                        Log.e("1", "run:--------->66tanweiOrder: " + tanweiOrder);
                        Log.e("1", "run:--------->3333333 ");
                        // showFrag(mTanweiFragment1);
                    }
                }
                // int tanweiNum = boothCounts.size();
                // Log.e("1", "run:--------->tanweiNum: " + tanweiNum);
                // for (int i = 1; i <= tanweiNum + 1; i++) {
                // tempButton = new RadioButton(mBaseActivity);
                // tempButton.setBackgroundResource(R.drawable.tanwei1_selector);
                // // 设置RadioButton的背景图片
                // tempButton.setButtonDrawable(null); // 设置按钮的样式
                // // tempButton.setPadding(80, 0, 0, 0); // 设置文字距离按钮四周的距离
                //
                // tempButton.setText("摊位 " + i + " (" + tanweiOrder + "单" +
                // ")");
                // mRgNavi.addView(tempButton,
                // LinearLayout.LayoutParams.WRAP_CONTENT,
                // LinearLayout.LayoutParams.WRAP_CONTENT);
                //
                // if (i == 1) {
                // // radioGroup.check(radioButton.getId());
                // tempButton.setChecked(true);
                // showFrag(mTanweiFragment1);
                // }
                //
                // }

                // Log.e("1", "run:--------->666666 ");
                // mTvTanwei1Num.setText(boothCounts.get(0).getOrderCount() +
                // "");
                // mTvTanwei2Num.setText(boothCounts.get(1).getOrderCount() +
                // "");
                // mTvTanwei3Num.setText(boothCounts.get(2).getOrderCount() +
                // "");

            }

            @Override
            public void onFailure(int code, String message) {
                // TODO Auto-generated method stub

                Toast.makeText(getApplication(), message, Toast.LENGTH_SHORT).show();

            }

        });
    }

你可能感兴趣的:(Android)