2013-03-12 40 views
-2

我已经使用该模板在android中创建制表符和滑动过程,但现在还无法在主活动中创建列表。我如何结合以下两段代码?在主要活动中合并代码

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/pager" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" /> 


<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<ListView 
    android:id="@+id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:divider="#b5b5b5" 
    android:dividerHeight="1dp" 
    android:listSelector="@drawable/list_selector" /> 

</LinearLayout> 

回答

0

线

<?xml version="1.0" encoding="utf-8"?> 

有去一切之上。 ViewPager不应该是您的布局的根元素。我建议将LinearLayout设置为主布局的根元素,并将ViewPager设置为孩子。

我猜this tutorial可能会有所帮助。它采用Android的Fragments

+0

我会为你投票,但我的声望不会让我。虽然谢谢! – PRCS 2013-03-13 12:44:59

+0

没关系:)你有没有让你的布局工作? – twigmac 2013-03-13 16:21:31