2013-08-21 14 views
0

我跟着這個教程http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/圖標的選項卡不顯示的指標

但我需要的圖像顯示出來,所以我複製一個48x48的PNG文件加載到繪製,華電國際和chnaged初始化主機

裏面的代碼耳線
 TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Tab 1", getResources().getDrawable(R.drawable.photos_white)), 
      (tabinfo = new TabInfo("Tab1", TabFragment1.class, args))); 
    TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Tab 2", getResources().getDrawable(R.drawable.photos_white)), 
      (tabinfo = new TabInfo("Tab2", TabFragment2.class, args))); 
    TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator("Tab 3",getResources().getDrawable(R.drawable.photos_white)), 
      (tabinfo = new TabInfo("Tab3", TabFragment3.class, args))); 

我在做什麼錯?該圖標不顯示。

爲清晰起見,整個方法:

private void initializeTabHost(Bundle args) { 
    mTabHost = (TabHost)findViewById(android.R.id.tabhost); 
    mTabHost.setup(); 
    TabInfo tabinfo = null; 
    TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("Tab 1", getResources().getDrawable(R.drawable.photos_white)), 
      (tabinfo = new TabInfo("Tab1", TabFragment1.class, args))); 
    TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("Tab 2", getResources().getDrawable(R.drawable.photos_white)), 
      (tabinfo = new TabInfo("Tab2", TabFragment2.class, args))); 
    TabsFragmentActivity.addTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator("Tab 3",getResources().getDrawable(R.drawable.photos_white)), 
      (tabinfo = new TabInfo("Tab3", TabFragment3.class, args))); 
    this.mapTabInfo.put(tabinfo.tag, tabinfo); 
    this.onTabChanged("Tab1"); 
    mTabHost.setOnTabChangedListener(this); 

} 

回答

0

原因是某些手機不顯示圖標,顯然我是用手機。我使用圖標和文本創建了一個視圖,並使用了該重載。

相關問題