【发布时间】:2015-11-04 07:33:38
【问题描述】:
我试图用我从服务中获得的数据替换与片段连接的文本视图。但即使我在 Activity 中使用 LayoutInflator 来编辑这些编辑文本,我也无法更改它们。我所了解的是,我需要从片段中更改它们,但我需要为此将数据从活动发送到片段,而我无法再次实现。
这是我在 MainActivity
的 onCreate 中编写的代码行 LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View mView = layoutInflater.inflate(R.layout.tab_designreservation, null);
Bundle extrasofuser = getIntent().getExtras();
nameofuser = extrasofuser.getString("nameofuser").toString();
surnameofuser = extrasofuser.getString("surnameofuser").toString();
EditText enum_of_name = (EditText) mView.findViewById(R.id.et_name);
EditText enum_of_surname = (EditText) mView.findViewById(R.id.et_surname);
enum_of_name.setText(nameofuser);
enum_of_surname.setText(surnameofuser);
据我所知,我需要将这些字符串变量发送到片段,但我做不到。感谢您的帮助!!
【问题讨论】:
标签: java android android-fragments android-intent bundle