当我尝试使用图标和文本进行TabHost时,只有文本可见,如果我将文本留空,则可以看到图标。我想在屏幕上看到两个。我试图用布局和Inflater做到这一点但没有成功。你可以检查我的代码中有什么问题吗?
TabHost tabHost = (TabHost)findViewById(R.id.tabHost);
Intent intent = new Intent(this,activity1.class);
TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("SMS");
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_layout, tabHost.getTabWidget(), false);
TextView title1 = (TextView) tabIndicator.findViewById(R.id.my_text);
title1.setText("SMS");
ImageView icon1 = (ImageView) tabIndicator.findViewById(R.id.my_image);
icon1.setImageResource(R.drawable.ajout);
tabSpec1.setIndicator(tabIndicator);
tabSpec1.setContent(intent);
tabHost.addTab(tabSpec1);
Intent intent1 = new Intent(this, activity1.class);
TabHost.TabSpec spec2 = tabHost.newTabSpec("MMS");
View tabIndicator1 = LayoutInflater.from(this).inflate(R.layout.tab_layout, tabHost.getTabWidget(), false);
TextView title2 = (TextView) tabIndicator.findViewById(R.id.my_text);
title2.setText("MMS");
ImageView icon2 = (ImageView) tabIndicator.findViewById(R.id.my_image);
icon2.setImageResource(R.drawable.suppression);
spec2.setIndicator(tabIndicator1);
spec2.setContent(intent1);
tabHost.addTab(spec2);