unable to show friends' name on chat

后端 未结 2 917
清歌不尽
清歌不尽 2021-01-29 04:29

I have problem to show the friend name on my chat. the apps force close every time run to show the friend\'s name. if i comment the part for friend\'s name, the messages can app

2条回答
  •  盖世英雄少女心
    2021-01-29 05:11

    All your setText, Toast, etc... actions should be done in the UI thread.

    For instance, stuff like: friendLabel.setText(name);

    In order to fix that, I would suggest you to do that inside the onPostExecute:

        @Override
        protected void onPostExecute(JSONArray result) {
            updateUI();// Do whatever you want here
        }
    

    From: http://developer.android.com/reference/android/os/AsyncTask.html

    onPostExecute(Result), invoked on the UI thread after the background computation finishes. The result of the background computation is passed to this step as a parameter.

提交回复
热议问题