[android-developers] Re: orientation changes for layouts
Thanks for the reply,sorry for the delayed response that will only work if i want to create a view. but what if the view is the same and i want to attached a dynamically created object from the layout, for example a new keyboard inside a view. you switch the keyboard using the new layout but the view is the same. this is why i need to get the resId and parse the xml and not use inflate On Sat, Oct 17, 2009 at 2:44 AM, Mark Murphy wrote: > > Spektor Yaron wrote: > > Thanks again, > > so i went ahead and implemented that and then found out that this: > > public XmlResourceParser getXml(int id) throws NotFoundException { > > return loadXmlResourceParser(id, "xml"); > > } > > > > does not find the resource id if the layout is in layout-land (it does > > find it if it is in layout though) > > any way to work around this? > > If you want to use a layout file, call setContentView() on your > activity, or call getLayoutInflater().inflate(). > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > _Android Programming Tutorials_ Version 1.0 In Print! > > > > -- Yaron Spektor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Spektor Yaron wrote: > Thanks again, > so i went ahead and implemented that and then found out that this: > public XmlResourceParser getXml(int id) throws NotFoundException { > return loadXmlResourceParser(id, "xml"); > } > > does not find the resource id if the layout is in layout-land (it does > find it if it is in layout though) > any way to work around this? If you want to use a layout file, call setContentView() on your activity, or call getLayoutInflater().inflate(). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 In Print! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Thanks again, so i went ahead and implemented that and then found out that this: public XmlResourceParser getXml(int id) throws NotFoundException { return loadXmlResourceParser(id, "xml"); } does not find the resource id if the layout is in layout-land (it does find it if it is in layout though) any way to work around this? On Sat, Oct 17, 2009 at 12:47 AM, Mark Murphy wrote: > > Spektor Yaron wrote: > > Thanks got it, > > but the point still is that Android would not know that layout3 and > > layout1 are the same and so if i am in layout3 it will not switch to > > layout1 when an orientation change occurs, right? > > Correct. > > Android does not support the notion of accessing two resources with the > same name from different resource sets at the same time (unless there's > an API for that which I have not seen, which is certainly possible). > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > Android App Developer Books: http://commonsware.com/books.html > > > > -- Yaron Spektor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Spektor Yaron wrote: > Thanks got it, > but the point still is that Android would not know that layout3 and > layout1 are the same and so if i am in layout3 it will not switch to > layout1 when an orientation change occurs, right? Correct. Android does not support the notion of accessing two resources with the same name from different resource sets at the same time (unless there's an API for that which I have not seen, which is certainly possible). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Thanks got it, but the point still is that Android would not know that layout3 and layout1 are the same and so if i am in layout3 it will not switch to layout1 when an orientation change occurs, right? On Sat, Oct 17, 2009 at 12:25 AM, Mark Murphy wrote: > > Spektor Yaron wrote: > > by calling the layout-land "layout3" i loose the android built-in method > > to switch to it when the orientation changes. > > That is not what I wrote. > > Copy layout/layout1 to layout/layout3. Then, all three are available > under unique identifiers. > > You still have a landscape layout1 that would override the default > layout1 when the device is in landscape mode. > > > that is why i added a proposed solution for that - call the get > > getResources().getConfiguration().orientation myself and figure out > > which layout to switch to. are you saying it wouldn't work? > > No, I am saying having your own subdirectories under layout/ will not > work. I now realize that is not what you meant, and I apologize for my > error. > > You are welcome to: > > 1. Add android:configChanges="keyboardHidden|orientation" to the > element of the AndroidManifest.xml file for whatever activity > or activities you want. > > 2. Override onConfigurationChanged() in those activities -- that method > will be called when the configuration does change. > > 3. Do whatever you want to affect the orientation change (e.g., call > setContentView() on whatever layout suits your fancy). > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > Android App Developer Books: http://commonsware.com/books.html > > > > -- Yaron Spektor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Spektor Yaron wrote: > by calling the layout-land "layout3" i loose the android built-in method > to switch to it when the orientation changes. That is not what I wrote. Copy layout/layout1 to layout/layout3. Then, all three are available under unique identifiers. You still have a landscape layout1 that would override the default layout1 when the device is in landscape mode. > that is why i added a proposed solution for that - call the get > getResources().getConfiguration().orientation myself and figure out > which layout to switch to. are you saying it wouldn't work? No, I am saying having your own subdirectories under layout/ will not work. I now realize that is not what you meant, and I apologize for my error. You are welcome to: 1. Add android:configChanges="keyboardHidden|orientation" to the element of the AndroidManifest.xml file for whatever activity or activities you want. 2. Override onConfigurationChanged() in those activities -- that method will be called when the configuration does change. 3. Do whatever you want to affect the orientation change (e.g., call setContentView() on whatever layout suits your fancy). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Thanks, by calling the layout-land "layout3" i loose the android built-in method to switch to it when the orientation changes. that is why i added a proposed solution for that - call the get getResources().getConfiguration().orientation myself and figure out which layout to switch to. are you saying it wouldn't work? if so, why? and what would work? On Sat, Oct 17, 2009 at 12:04 AM, Mark Murphy wrote: > > Spektor Yaron wrote: > > i have a layout folder with 2 layouts. layout1 and layout2 > > i have another folder layout-land that has layout1 in it. > > i would like to be able to get to all the layouts so i could create a > > set of layout like this: > > {layout1, layout2, layout1(from layout-land folder)} > > is there any way i can use the existing android mechanisim to do that? > > Copy layout/layout1 to layout/layout3. Then, all three are available > under unique identifiers. > > > if not, what would be the impact of creating my own definition of the > > layout folder (for example to have under the layout folder layout1, > > layout2 and layout_land1 and have my code do getOrientation to > > diffrentiate whcih one should be presented) > > It won't work. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > Android App Developer Books: http://commonsware.com/books.html > > > > -- Yaron Spektor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: orientation changes for layouts
Spektor Yaron wrote: > i have a layout folder with 2 layouts. layout1 and layout2 > i have another folder layout-land that has layout1 in it. > i would like to be able to get to all the layouts so i could create a > set of layout like this: > {layout1, layout2, layout1(from layout-land folder)} > is there any way i can use the existing android mechanisim to do that? Copy layout/layout1 to layout/layout3. Then, all three are available under unique identifiers. > if not, what would be the impact of creating my own definition of the > layout folder (for example to have under the layout folder layout1, > layout2 and layout_land1 and have my code do getOrientation to > diffrentiate whcih one should be presented) It won't work. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---