需要在onPostExecute
级内从onCreateView
向Fragment
函数发送值。我在Fragment
类中创建了一个newInstance(String value)方法,并从onPostExecute
调用此函数。该值出现在newInstance方法中,但在将值发送到onCreateView
时,该值为null。
onPostExcute(String result){
FragmentClass.newInstance(result);
}
public static FragmentClass newInstance(String value){
Log.i("New Instance",value);//works fine value is printed here
EmployeeBranch fragment = new EmployeeBranch();
Bundle args = new Bundle();
args.putString("key", value);
fragment.setArguments(args);
return fragment;
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle args = getArguments();
String output=getArguments().getString("key","default");
Log.i("Output",output);//null value
}
}