您好,我正在使用Material Stepper踏石 在每一步中,我都将数据存储在单例类中,并在最后一步中检索它们以进行订单检查,并且一切与Spinners,RadioButtons,CheckBoxes都可以正常工作,除了最后一步之前的步骤(我要用户使用EditText)输入评论,我应该检索该评论并将其显示在“订单审阅”步骤中,但是当我尝试将EditText更改为任何其他视图时,它不会显示出来
评论步骤:
public class CommentsStep extends Fragment implements BlockingStep {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_comments_step, container, false);
final EditText testFinal = (EditText) view.findViewById(R.id.testFinal);
Button testing = (Button)view.findViewById(R.id.testing);
testing.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stepperSingleton.getInstance().setComments(testFinal.getText().toString());
}
});
return view;
}
订单审核步骤 :
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_order_review, container, false);
TextView car_id = (TextView)view.findViewById(R.id.CarID);
TextView service_type = (TextView)view.findViewById(R.id.ServiceType);
TextView comments = (TextView)view.findViewById(R.id.extraComments);
TextView provider = (TextView)view.findViewById(R.id.Provider);
TextView date = (TextView)view.findViewById(R.id.Date);
TextView time = (TextView)view.findViewById(R.id.Time);
TextView filters = (TextView)view.findViewById(R.id.filters);
TextView oil = (TextView)view.findViewById(R.id.OilType);
if(stepperSingleton.getInstance().getFilters()!=null){
for(String x : stepperSingleton.getInstance().getFilters().values()){
filters.append(x+"\n");
}
}
comments.setText(stepperSingleton.getInstance().getComments());
oil.setText(stepperSingleton.getInstance().getOilType());
car_id.setText(stepperSingleton.getInstance().getCarID());
service_type.setText(stepperSingleton.getInstance().getServiceType());
provider.setText(stepperSingleton.getInstance().getGarageType());
date.setText(stepperSingleton.getInstance().getDate());
time.setText(stepperSingleton.getInstance().getTime());
return view;
}
我尝试了所有操作,包括使用addTextChangeListener而不是使用按钮,问题是从EditText获取文本并将其存储在singleton类中,当我将其从单例调用回下一步以将其存储在文本视图中时似乎没有输入任何内容