0

我怎样才能做到这一点?

没有视图显示...

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.details, container, false);

        InitAlerts();
        return v;
    }

    private void InitAlerts()
    {
        //TODO Find step number
        //Temp: already set to 1

        if(stepNum == 1) {
            startStepOne();
        } else if(stepNum == 2) {
            startStepTwo();
        } else {
            startStepSummary();
        }
    }

    private void startStepOne() {
        LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
        View v = inflater.inflate( R.layout.usage_alerts_step_one, null, false);
        alertsStepOneConfirm = (Button) v.findViewById(R.id.alertsStepOneConfirm);
        alertsStepOneConfirm.setOnClickListener(this);
        v.bringToFront();
    }

    private void startStepTwo() {
        LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
        View v = inflater.inflate( R.layout.usage_alerts_step_two, null, false);
        stepTwoConfirm = (Button) v.findViewById(R.id.stepTwoConfirm);
        stepTwoConfirm.setOnClickListener(this);
        v.bringToFront();
    }
4

1 回答 1

1

1) 在 R.layout.details 布局上调用 addView 方法,并以相应的步骤视图为参数。您需要从每个 step* 方法返回膨胀视图。

2)如果你不需要R.layout.details,你可以让onCreateView返回对应步骤的视图

于 2012-11-22T01:55:51.810 回答