matghazaryan
matghazaryan

Reputation: 5896

portrait and landscape advice

I have 2 xml file (main.xml) one in layout, one in layout-land. in that xml I have a listView. So when I run my application in landscape mode and after that turn device in portrait mode it is working fine but when I run my application in portrait mode and turn in landscape mode, the data of listView not loading anymore. I don't understand what's problem could I have here. Landscape -> portrait is fine, portraid -> landscape is bad. Is there any idea of this.

loading data here.

 public void loadData(final User user) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    init(user);
                    getUserGroups(user.getSocialAcountByName("way").getSocial_uid(), "way");
                }
            }); 
        }

Upvotes: 0

Views: 260

Answers (1)

pablochan
pablochan

Reputation: 5715

The problem is with your activities' lifecycle. If you just load the data in onCreate you're going to lose it everytime the activity restarts (and this might happen anytime). So you probably just need to move the data loading to onResume to be safe.

Upvotes: 2

Related Questions