2016-03-06 114 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

請編輯和顯示整個類。 –

回答