hi, I am loading more than 500 items in a listview from a Web API. Each list item contains one imageview and two text views. But while loading these huge items, when we rotate the screen, a portion of the screen will become black as shown in the figure and after 10 or 20 seconds it will be okay. It is happening in almost all android devices like samsung duos and nexus 9 tablet I am sure that nothing is blocking the UI main thread. SO please suggest a solution to this problem
Asked
Active
Viewed 3,947 times
3
-
1I guess some of your code blocking your UI – Amsheer Sep 17 '15 at 07:08
-
A quick fix but not pretty is to block the orientation during loading. – JDenais Sep 17 '15 at 07:08
-
Are you using different layout for landscape and portrait? – Amsheer Sep 17 '15 at 07:09
-
@Amsheer :-->I am using the same layout for landscape and portrait – Sandeep Sep 17 '15 at 07:23
-
@user1310348 How did you making web call? Use AsyncTask? – Amsheer Sep 17 '15 at 09:41
-
@ Amsheer -->Using the AsyncTask – Sandeep Sep 17 '15 at 09:44
2 Answers
0
This happens due to the view being reloaded into memory. In Android it is possible to have different layouts for each orientation. That is why the view needs to be reloaded and if there are many many elements as in your case this becomes visible.
There are several solutions. You basically need to tell Android that you will handle orientation changes yourself. Please check the amswer here: Don't reload application when orientation changes

Community
- 1
- 1

Niki van Stein
- 10,564
- 3
- 29
- 62
0
You can remove this black screen space by making your layout to alignparentRight and alignparentLeft to TRUE.

KishuDroid
- 5,411
- 4
- 30
- 47