问题
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