Using ViewSwitcher with Eclipse IDE

旧街凉风 提交于 2019-12-11 13:50:04

问题


I am new to android programming, and I am using eclipse. I am using ViewSwitcher, and able to switch back and forth between views.

My question is with eclipse.

In eclipse, how can I edit the different layouts graphically? Only the first layout is visible when I select the res->layout->main.xml.

I know there is a work around (or may be even the right approach); having two layout files, and switching between them. But that is not my intention right now.

Thanks for any suggestions. Karthik


回答1:


Its a bit late but I had the same problem and got around it with only xml changes by putting the contents of the 2 layouts in other files and including them in the original file. Not sure if this is proper but it made it easier to test.

<ViewSwitcher
    android:id="@+id/detailSwitcher"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

    <include  
        layout="@layout/layout_file_1" /> 

    <include  
        layout="@layout/layout_file_2" /> 
</ViewSwitcher>



回答2:


I would not create a view graphically. It is really easy to type in the XML and then you know you are making exactly what you want. Use the GUI to check your work. I would certainly build the two layouts in separate files and then paste them into the one with the view switcher when you have it just as you want it.




回答3:


You just have to change the sequence of the layouts in the view switcher. The first layout in the viewswitcher is visible in eclipse. Edit your first layout which is in the viewswitch and then move the second up to work on it.



来源:https://stackoverflow.com/questions/9068945/using-viewswitcher-with-eclipse-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!