2013-07-11 77 views
-1

我設置了沒有TabActivity的標籤, 所以我的tabHost總是有錯誤。 請告訴我該怎麼做。 謝謝。如何在沒有TabActivity的情況下設置自定義tabhost樣式

private void setupTab(Class<?> ccls, String name, String label, 
     Integer iconId) { 
    Intent intent = new Intent().setClass(this, ccls); 

    View tab = LayoutInflater.from(this).inflate(R.layout.custom_tab, null); 
    ImageView image = (ImageView) tab.findViewById(R.id.icon); 
    TextView text = (TextView) tab.findViewById(R.id.text); 
    if (iconId != null) { 
     image.setImageResource(iconId); 
    } 
    text.setText(label); 

    TabSpec spec = tabHost.newTabSpec(name).setIndicator(tab) 
      .setContent(intent); 
    tabHost.addTab(spec); 

} 

我讀Android Tab-Host 賺取

+0

打印你logcat什麼是錯誤。 –

回答

0

它不能建立。 我被tabHost運行錯誤無法解析。

相關問題