defined xml layout in layout-land does not appear in android application -
i developing application according this example. defined landscape layout header.xml in layout-land folder, when change orientation landscape, defined layout not appear in screen.
do know why ?
thanks
updated :
activity code :
public class acenewsfeedactivity extends listactivity { // progress dialog private progressdialog pdialog; // array list list view arraylist<hashmap<string, string>> rssitemlist = new arraylist<hashmap<string,string>>(); rssparser rssparser = new rssparser(); list<rssitem> rssitems = new arraylist<rssitem>(); rssfeed rssfeed; private static string tag_title = "title"; private static string tag_link = "link"; private static string tag_desription = "description"; private static string tag_pub_date = "pubdate"; //private static string tag_guid = "guid"; // not used /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.rss_item_list); /** * calling backgroung thread loads recent articles of website * @param rss url of website * */ new loadrssfeeditems().execute(); } .... } xml layout in landscape mode :
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layoutheader" android:layout_width="fill_parent" android:layout_height="50dip" android:layout_alignparenttop="true" android:background="@layout/header_gradient" android:orientation="horizontal"> <!-- logo --> <!-- refresh --> <!-- plus button --> <imagebutton android:id="@+id/btnaddsite" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_marginright="5dip" android:background="@null" android:src="@drawable/plus" android:layout_centervertical="true" /> <imageview android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:src="@drawable/logo" /> <imageview android:id="@+id/refreshlist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" android:src="@drawable/refresh" /> </relativelayout>
android allows provide different versions of resource files support specific device configurations including screen size/resolution , (as trying do) device orientation. when android loading layout file first in res/layout-port folder (if in portrait orientation) or in res/layout-land folder (if in landscape orientation). if doesn't find file in regular res/layout folder.
additionally, noted here, when device configurations change (like device orientation) during runtime android restart whatever process running saving state, destroying it, , starting saved state info. allows load layout files again, , folder new orientation when tries load them.
so, if start application in portrait load file in res/layout-port or res/layout. if rotate device landscape destroy process , restart. however, time in landscape check res/layout-land instead layout files.
if have files set way not operating think should, i'd first verify not using correct files putting 2 different header.xml files in layout-land , layout-port folders, maybe 1 red background , 1 green background. make sure double-check file references , maybe use toast post debugging info on-screen ensure inflating layouts properly.
the default behavior android handle orientation change (which involves destroying activity , creating new instance of reload layout files). default behavior occur unless activity tag in manifest file contains property android:configchanges="orientation". (this tag can take arguments other orientation - android handle config changes events except ones pass arguments tag.)
if include android:configchanges="orientation" tag telling android not destroy activity , not reload layout files when orientation of device changes. instead of default behavior call method (which define) allow make changes wish make handle orientation change rather letting android handle automatically. it's intended if destroying activity major inconvenience doesn't have automatically destroyed.
edit: added things comment discussion
Comments
Post a Comment