我有两个班。首先是活动的,第二个是一个片段,我有一些edittexts。在活动我有一个子类,异步任务和方法 doInBackground
我得到了一些成绩,这是我保存到变量。我如何发送此变量子我的活动这个片段?
I have two classes. First is activity, second is a fragment where I have some edittexts. In activity I have a subclass with async task and in method doInBackground
I get some result, which I save to variable. How can I send this variable from subclass "my activity" to this fragment?
从活动发送的数据,意图为:
From Activity you send data with intent as:
Bundle bundle = new Bundle();
bundle.putString("edttext", "From Activity");
// set Fragmentclass Arguments
Fragmentclass fragobj = new Fragmentclass();
fragobj.setArguments(bundle);
和在片段onCreateView方式:
and in Fragment onCreateView method:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String strtext = getArguments().getString("edttext");
return inflater.inflate(R.layout.fragment, container, false);
}
上一篇:如何使用AWS上的电磁辐射-libjars?电磁辐射、如何使用、AWS、libjars
下一篇:android.util.AndroidRuntimeException:不能将刷卡解雇和操作栏能将、操作、android、util