Issue
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?
Solution
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
Answered By - Sandip Fichadiya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.