2016-03-06 161 views
0

我尝试使用this tutorial创建标签栏。但是,在这条线:getTabHost() - 无法解析方法

TabHost tabHost = getTabHost(); 

我收到的消息:

无法解析的方法 “getTabHost()”

这是我的代码:

protected void onCreate(Bundle savedInstanceState) { 

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

    //add tab bar 
    TabHost tabHost = getTabHost(); 
    TabHost.TabSpec spec; 
    Intent intent; 

    intent = new Intent().setClass(this, FeedsFriendsActivity.class); 
    spec = tabHost.newTabSpec("First").setIndicator("First") 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, FeedsBeersActivity.class); 
    spec = tabHost.newTabSpec("Second").setIndicator("Second") 
      .setContent(intent); 
    tabHost.addTab(spec); 

    intent = new Intent().setClass(this, FeedsNotificationActivity.class); 
    spec = tabHost.newTabSpec("Third").setIndicator("Third") 
      .setContent(intent); 
    tabHost.addTab(spec); 

} 

我该如何解决它?

+0

请编辑和显示整个类。 –

回答