80,469
社区成员




// th_host = (TabHost) this.findViewById(R.id.th_host);
th_host = getTabHost();
TabSpec ts_list = th_host.newTabSpec("List");
ts_list.setIndicator("列表",
getResources().getDrawable(R.drawable.list));
ts_list.setContent(R.id.lv_address);
th_host.addTab(ts_list);
TabSpec ts_edit = th_host.newTabSpec("Edit");
ts_edit.setIndicator("添加",
getResources().getDrawable(R.drawable.restaurant));
ts_edit.setContent(R.id.tb_details);
th_host.addTab(ts_edit);
final boolean exclusive = iconView.getVisibility() == View.GONE;
final boolean bindIcon = !exclusive || TextUtils.isEmpty(mLabel);
if (bindIcon && mIcon != null) {
iconView.setImageDrawable(mIcon);
iconView.setVisibility(VISIBLE);
}
这里有一个exclusive判断ImageView是否显示。再看对应的tab_indicator_holo.xml文件。
<ImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:visibility="gone" />
看到没有,这里是不显示图片的,也就是说,只有在文字为空的时候才显示图片。
个人理解是android自己定义的布局吧。
如果你把AndroidManifest.xml中的代码去掉:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
是可以显示的,应该是以前的代码支持双显示吧。------以上为个人想法。