2011-07-26 25 views
0

我需要設置圖像到選項卡主機中的每個選項卡小部件。 我設置使用host.addTab(host.newTabSpec( 「AAA」) .setIndicator( 「A」,getResources的圖像()getDrawable(R.drawable.my_tabselector));如何設置一個圖像(無文本)tabgers android 1.6

,但它不適合於。標籤(標籤wiget是大於我的形象)

plase幫我謝謝

回答

1

這樣做是爲了使標籤只有一個形象:

tabHost.addTab(tabHost.newTabSpec("aaa").setIndicator("", getResources().getDrawable(R.drawable.my_tabselector)).setContent(R.id.my_tab_contentlayout)); 
+0

感謝ü非常host.getTabWidget()不寫任何文字getChildAt(1).setBackgroundResource(R.drawable.myimage)。解決我的問題。 – rwe

0

您可以用這種方式TI海特標籤標題:

for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) 
    { 
     View view = tabHost.getTabWidget().getChildAt(i); 
     view.findViewById(android.R.id.title).setVisibility(View.GONE); 
    } 
0
 TabHost tabHost = getTabHost(); 

     Intent intent; 

     intent = new Intent(MainActivity.this, SecondActivity.class); 

     tabHost.addTab(tabHost.newTabSpec("").setIndicator("", getResources().getDrawable(R.drawable.home_selected)).setContent(intent)); 

     intent = new Intent(MainActivity.this, Calendar.class); //2 

     tabHost.addTab(tabHost.newTabSpec("").setIndicator("",getResources().getDrawable(R.drawable.calender_unselect)).setContent(intent)); 

setIndicator("Tab text", getResource(). ...)

相關問題