我有一个 Android 片段。当我创建视图时,我用模型中的值填充布局中的字段。在某一时刻,我想使用相同的类模型但使用其他值重新创建视图。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater
.inflate(R.layout.item_view, container, false);
editText = (EditText) v.findViewById(R.id.question_text);
questionText.setText(myModel.getName());
---------------
}
我有一个私有函数,它会在点击视图时调用
private void recreateView(MyModel model){
myModel = model;
//here I want to recall onCreateView or something like that but I don't know if that is ok, or is a more simple way to do that
}