开发者

how to load different xml file in orientation change in android

can anybody tell how to load different xml file whenever user changes device orientation in android?

For example, I am using a profile screen in my application. In portrait mode, user gives 'user name' value, after that I change orientation to landscape, now I have to load different xml, so that user gives value in landsacpe mode.

Is it possible?

Thanks

Editor's Note: English doesn't seem 开发者_运维百科to be his first language.


create two types of layout directories to handle orientation . layout-land layout-port put the xml with the same name in both the directory. if i have main.xml file then i have to put it in both directory.

Thanks


Provide a different layout in layout-land\ See http://developer.android.com/guide/topics/resources/providing-resources.html


yes it is possible. If the user has changed the orientation then you can set different XML on setContentView(R.id.xml)


You need to implement OnConfigChange Method so when ever orientation change at that time this method will call autmatically and setContentView(R..id.nameofxml) from layout-land folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜