I call AsyncTask in the snippet. I go through all the stages normally, but in the onPostExecute() method I need to fill in a TextView . Here is the fragment code:

 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.info_fragment, container, false); tv = (TextView) v.findViewById(R.id.textViewFIO); tv.setText("TEXT"); new GetUserInformation(getActivity(), "zz@zz"); setTextTV("ADSDADAD"); return v; } 

And onPostExecute () itself:

 protected void onPostExecute(String result) { super.onPostExecute(result); tv.setText(otvet) } 

The answer is not null. I need to fill the TextView . How to be?

  • So what's the problem? - temq
  • @temq, the problem is that the text still does not change, although it was implemented in activity and norms. - Dmitriy Koverko
  • Well, it means not implemented as in the activation, attach the full code of the asink task. Now, judging by your onPostExecute , you should see otvet if it really comes. TextView then located in the snippet? - temq

1 answer 1

If I understand you correctly, then you need to transfer some callback to AsyncTask and pull the method of this callback in the onPostExecute method

 public interface Callback{ onPostExecute(String result); } 

 new GetUserInformation(getActivity(), "zz@zz", new CallBack(){ onPostExecute(String result){ tv.setText(result) } }); 

GetUserInformation:

 private Callback callback; protected void onPostExecute(String result) { super.onPostExecute(result); callback.onPostExecute(result); }