-7

I use Asynctask to set the image to RecyclerView when the page is executed

Asynctask takes a recyclerView's width and height

However, this error occurs 'IllegalArgumentException: width should be > 0'

I looked up similar cases and saw that it was a problem to run too soon

So I tried onPause, onStart, and onPostCreated, but the same result came up

Put it in the button and run it to get the result I want

Therefore, I think that the point of execution is the problem

When should I call this method to get the page to run and immediately set the

image to recyclerView?

Chithra B
  • 586
  • 2
  • 9
Jshin
  • 131
  • 2
  • 9

1 Answers1

-1

Without any code from your end, what I can suggest is to do something like :

recyclerView.post(new Runnable() {
                @Override
                public void run() {
                     // Execute your AsyncTask here by providing Width
                }
            });

Because the problem I can guess is your RecyclerView is not properly inflated when you call the AsyncTask with width

Also I would suggest you to put the method after you call setAdapter

Sandip Fichadiya
  • 3,430
  • 2
  • 21
  • 47
  • I will have to enter code and error next time. Thank you for your advice. Have a nice day! – Jshin Feb 05 '18 at 11:30