I have a class that is connected to a socket and constantly receives data from it. I divide them into separate commands and pass to the parser. The question is this: when I click on an item in my list, I send a command to the server (request for information about this item in the list), I activate it, and after the parser receives the response command (json with data) I have to fill in the text fields with the information received. How can I implement the field filling mechanism only after receiving the command?
1 answer
Good day. So what will they fill in without data? On arrival of json'a you call a method which fills all fields.
public void JSONCallback(Json json){ SomeClass smth= new Gson().fromJson(json, SomeClass.class); textView.setText(smth.getText()); //etc.. } If necessary, make the fields inaccessible for editing after clicking the button, and in the JSONCallback method make them available
- in the parser I call JSONCallback () in which I transfer the already prepared values for the TextView, on the line setText (...) the error appears: java.lang.RuntimeException: Can not create a looper Lysenko
- Try calling the setText (...) method in another, not UI, thread, or use AsyncTask, or Handler. Source - timuruktus
- I've tried everything, the same error crashes - Heorhii Lysenko
|