2011-07-10 3 views
1

私は自分のTabActivityにカスタムタイトルを付けたいと思っています。しかし、以下のコードは機能しません。コードの何が間違っていますか?そして、私はどのようにTabActivityのカスタムタイトルを作ることができますか?ありがとうございました!Android:TabActivityのカスタムタイトルを作成する方法

public class ShowExam_TabAct extends TabActivity { 
public static boolean customTitleSupported = false; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.tabs); 

    customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
    if (customTitleSupported) { 
     getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, 
        R.layout.title); 
     TextView title = (TextView) findViewById(R.id.TV_title); 
     title.setText("new title!"); 
    } 

    TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); 

    tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Mars") 
      .setContent(new Intent(this, List1.class))); 
    tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Earth") 
      .setContent(new Intent(this, List2.class))); 

} 
} 
+0

でみては? – kinghomer

答えて

0

エラーが出てきている何このよう

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 

     getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); 

     setContentView(R.layout.main); 

     if(customTitleSupported){ 
      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); 
     } 

     TextView title = (TextView) findViewById(R.id.TV_title); 
     title.setText("new title!"); 
     .... 
} 
関連する問題