2015-12-08 27 views
-1

我在我的android应用程序的标签布局上使用Listview从网络加载数据。 Tha标签工作正常,我可以很容易地在我的标签之间切换,而不会有任何错误,但是当listview使用来自服务器的数据填充时,标签消失,并且我有一个简单的带有数据的listview。我看不到其他标签了。 PS数据加载正常没有任何问题。使用ListView显示标签布局中的帖子

这里是home_layout

protected void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.home_layout); 

    TabHost tabHost = getTabHost(); 

    TabHost.TabSpec myprofiletab = tabHost.newTabSpec("Profile"); 
    myprofiletab.setIndicator("Profile",getResources().getDrawable(R.drawable.myprofile_icon)); 
    Intent myprofileintent = new Intent(this,MyProfile.class); 
    myprofiletab.setContent(myprofileintent); 

    TabHost.TabSpec newsfeedtab = tabHost.newTabSpec("NewsFeed"); 
    newsfeedtab.setIndicator("Feed",getResources().getDrawable(R.drawable.newsfeed_icon)); 
    Intent feed = new Intent(this,NewsFeed.class); 
    newsfeedtab.setContent(feed); 

    tabHost.addTab(newsfeedtab); 
    tabHost.addTab(myprofiletab); 
} 

这里首页Java代码的home_layout

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_alignParentBottom="true" 
android:layout_height="fill_parent"> 
<RelativeLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"/> 
    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 
</RelativeLayout> 

回答

0

通过添加一行到我的FrameLayout解决我的问题

 <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@android:id/tabs" /> 
相关问题