I loaded the four fragments in a viewpager
Then in the second fragment wrote a recyclerview, and use okhttp parsing json after loading recyclerview
Then it is strange that every time I open the app, switch directly to the second fragment (viewpager initial shows the first fragments), recyclerview no load
Every time to switch to the fourth fragments
Then switch to the second
Recyclerview it would appear,
Want to for a long time can't imagine what it is, if I don't switch to the fourth fragments, in front of the viewpager 3 no matter how to switch pages, page 2 of recyclerview doesn't load
CodePudding user response:
Do you have a question, and that in itself is your networking within the child thread, adapter binding inside the UI thread, you should be at the back of the networking operation notice adapter updates, add the try on the end of the for loop adapter. The notifyDataSetChanged ();CodePudding user response:
You put initItem code in the onViewCreated, at that time the view to refreshCodePudding user response: