I want to display a View in my TabHost thanks to TabSpec, it does work on all my devices exept the Nexus 7.
Drawable img = getResources().getDrawable(R.drawable.tab_info_icon);
Intent intent = new Intent(context, Actus.class);
setupTab(img, intent);
private void setupTab(final Drawable image, final Intent intent) {
View tabview = createTabView(mTabHost.getContext(),image, intent);
TabSpec setContent = mTabHost.newTabSpec("").setIndicator(tabview).setContent(intent);
mTabHost.addTab(setContent);
}
private static View createTabView(final Context context, final Drawable image,final Intent intent) {
View view = LayoutInflater.from(context).inflate(R.layout.onglet, null);
LinearLayout ll = (LinearLayout)view.findViewById(R.id.fondOnglet);
ll.setBackgroundResource(R.drawable.tab_bg);
ImageView iv = (ImageView)view.findViewById(R.id.imgOnglet);
iv.setImageDrawable(image);
return view;
}
R.drawable.tab_info_icon is an xml selector.
This is strange, but the Nexus 7 is not hdpi or xhdpi, it’s tvdpi, so i created a drawable-tvdpi directory and put my images there, and it works.