AsyncTask OnPostExecute not updating TextView

后端 未结 2 612
死守一世寂寞
死守一世寂寞 2020-12-19 19:57

I have an AsyncTask running. I have a TextView that I mimic the message a Toast initially produces. I want to clear the TextView

2条回答
  •  旧时难觅i
    2020-12-19 20:09

    I know this thread is old, but I think I found the solution (at least it worked for me), perhaps it help others:

    I had a view with 3 textviews with default values receiving values from a webservices from "doInBackground" method of a AsyncTask and later changing the text in them on "onPostExecute" method. The issue was that only one of the three textviews was showing the new text from the ws in the first execution of code (it's a simple application implementing the Zxing barcode reader reading a barcode from a product and obtaining the price from a webserver, anyway), the next executions (after the app is opened) was updating the three textviews normally.

    So I noticed that the only textview that was updating its value in the first execution had its parameter "android:textIsSelectable" = true, the other two was false. Bingo, changing this parameter to true in the other 2 textviews solved the issue.

提交回复
热议问题