我怎样才能实现这个目标?
没有显示任何视图...
@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();
}
1) 在 R.layout.details 布局上调用 addView 方法,并以相应的步骤视图作为参数。您需要从每个步骤*方法返回膨胀的视图。
2)如果你不需要R.layout.details,你可以让onCreateView返回与步骤对应的视图