1

Okay, So I just started Android development (I am average at VB.Net, so I understand basic code even if its not in VB). I've made a couple play around apps which used Text-To-Speech, Async Tasks and Reading/Writing files. However, I now wish to make a tabbed Android app.

I started the project in Eclipse Juno and filled in all the details. I then selected (For navigation) the Tabs/Swipe layout. I now have the default code for that layout type (Link to Tabs on developer.android.com - http://developer.android.com/design/building-blocks/tabs.html).

I understand mostly what the default code is doing. The only problem I am having, is determining the individual layout of my Tabs. I wish to have 2 Tabs, 1 in which the user selects an option, and the other, in which an image is shown depending on the selection in Tab 1.

So the question is: How do I create a .xml file in Layout to determine what is shown on the Fragment?

4

1 回答 1

1

如果您想在 XML 中执行此操作,答案很简单,不能仅使用 XML 完成,您必须创建一个实现ActionBar.TabListener的类。

比您可以覆盖可以交换内容的onTabSelected方法。
一个合适的解决方案是:
使用 LinearLayout 作为根容器,并为每个选项卡实现两个片段(在那里您可以设计单独的 XML 布局)。现在,您可以最初将一个片段添加到根容器并在 onTabSelected 方法中实现布局交换,您就完成了。

于 2013-01-20T11:28:15.907 回答