在活动Android的ListView中得到刷新上更改方向 [英] Android ListView in Activity getting Refreshed on Changing Orientation

查看:158
本文介绍了在活动Android的ListView中得到刷新上更改方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ListView里面,并在活动我有$ C $下填充的ListView这一数据的数据的onCreate方法活动是一种基于服务器等填充包括呼叫网络的网址。我有相同的活动类的ListView的一个ArrayAdapter。

I have Activity with ListView inside it and in the onCreate method of the Activity I have code for populating the Data of the ListView this Data is a server based and so populating includes calling Network URLs. I have the ArrayAdapter of the ListView in the Same Activity Class.

现在我'所面临的问题是,在休息所有方案我的活动是表现在一个适当的方式,但在方向[纵向舍景观美化或其他方式]正在发生的数据迷路,更新的数据呼叫需要填充相同的旧数据,现在这是一件不打算出code我应该怎么处理它。

Now the Issue I'am facing is that, in Rest all scenarios my Activity is behaving in a proper way but when the Orientation [ Portrait to Landscaped or other way round] is taking place the Data is Getting lost and Newer Data calls are Required to Populate the Same Old Data now this is something that is not intended out the code how should I deal with it.

推荐答案

Android将停止并重新启动您的活动,除非你告诉它,你会处理的方向改变自己。它这样做,这样你可以指定不同的资源(比如布局)是定位特定的(以及其他原因)。

Android will stop and restart your activity unless you've told it you will handle orientation changes yourself. It does this so that you can specify different resources (such as layouts) that are orientation-specific (among other reasons).

您需要添加<一个href="http://developer.android.com/guide/topics/manifest/activity-element.html#config">android:configChanges="orientation"为您的活动delcaration在AndroidManifest.xml中,你需要重写<一个href="http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged%28android.content.res.Configuration%29">onConfigurationChanged().我不相信你需要做什么特别的事情里面onConfigurationChanged(),简单地实现它应该做的伎俩。

You need to add android:configChanges="orientation" to your activity delcaration in your AndroidManifest.xml, and you need to override onConfigurationChanged(). I don't believe you need to do anything special inside onConfigurationChanged(), simply implementing it should do the trick.

这篇关于在活动Android的ListView中得到刷新上更改方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆