android - Java Thread Message Passing -
I'm writing an Android app. I have a main method, which creates and runs a new thread using an anonymous Inner Runnabal class. Run () method, when this is done, then calls a method in its original class (in the main thread) that indicates the call Dataset Cheng () so that the main thread can reproduce new data. This is causing all kinds of problems (ViewRoot $ CalledFromWrongThreadException).
The thing is, this method, called a uniform thread, is a class created in that UI thread. Should not it run on the UI thread? Or am I missing something?
There is some code about what I'm talking about:
Public class enhances malmer activity {@ Override Public Wide On Crate (Bundle IKEIL) } {(New thread) {Public Zero Run} {// A group of slow network content Update ();}}) Start (); } Private Zero update () {myAdapter.notifyDatasetChanged (); }}
Did you try to call the UI updating code? Something like this:
Private Zero Update () {runOnUiThread {New Runnabal} {Public Zero Run} {myAdapter.notifyDatasetChanged ();}}}
Comments
Post a Comment