Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +28 −18 Original line number Original line Diff line number Diff line Loading @@ -67,8 +67,10 @@ import android.view.View.AttachInfo; import android.view.View.MeasureSpec; import android.view.View.MeasureSpec; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams; import android.widget.FrameLayout; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TabHost; import android.widget.TabHost; import android.widget.TabWidget; import android.widget.TabWidget; import android.widget.TabHost.TabSpec; import java.awt.Color; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Graphics2D; Loading Loading @@ -918,7 +920,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { /** /** * Returns the top screen offset. This depends on whether the current theme defines the user * Returns the top screen offset. This depends on whether the current theme defines the user * of the title and status bars. * of the title and status bars. * @param resolver The {@link ResourceResolver} * @param resolver The {@link RenderResources} * @param metrics The display metrics * @param metrics The display metrics * @return the pixel height offset * @return the pixel height offset */ */ Loading Loading @@ -1047,15 +1049,22 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { // now process the content of the framelayout and dynamically create tabs for it. // now process the content of the framelayout and dynamically create tabs for it. final int count = content.getChildCount(); final int count = content.getChildCount(); if (count == 0) { throw new PostInflateException( "The FrameLayout for the TabHost has no content. Rendering failed.\n"); } // this must be called before addTab() so that the TabHost searches its TabWidget // this must be called before addTab() so that the TabHost searches its TabWidget // and FrameLayout. // and FrameLayout. tabHost.setup(); tabHost.setup(); if (count == 0) { // Create a dummy child to get a single tab TabSpec spec = tabHost.newTabSpec("tag").setIndicator("Tab Label", tabHost.getResources().getDrawable(android.R.drawable.ic_menu_info_details)) .setContent(new TabHost.TabContentFactory() { public View createTabContent(String tag) { return new LinearLayout(mContext); } }); tabHost.addTab(spec); return; } else { // for each child of the framelayout, add a new TabSpec // for each child of the framelayout, add a new TabSpec for (int i = 0 ; i < count ; i++) { for (int i = 0 ; i < count ; i++) { View child = content.getChildAt(i); View child = content.getChildAt(i); Loading @@ -1071,6 +1080,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { tabHost.addTab(tabHost.newTabSpec(tabSpec).setIndicator(name).setContent(id)); tabHost.addTab(tabHost.newTabSpec(tabSpec).setIndicator(name).setContent(id)); } } } } } /** /** Loading Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +28 −18 Original line number Original line Diff line number Diff line Loading @@ -67,8 +67,10 @@ import android.view.View.AttachInfo; import android.view.View.MeasureSpec; import android.view.View.MeasureSpec; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams; import android.widget.FrameLayout; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TabHost; import android.widget.TabHost; import android.widget.TabWidget; import android.widget.TabWidget; import android.widget.TabHost.TabSpec; import java.awt.Color; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Graphics2D; Loading Loading @@ -918,7 +920,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { /** /** * Returns the top screen offset. This depends on whether the current theme defines the user * Returns the top screen offset. This depends on whether the current theme defines the user * of the title and status bars. * of the title and status bars. * @param resolver The {@link ResourceResolver} * @param resolver The {@link RenderResources} * @param metrics The display metrics * @param metrics The display metrics * @return the pixel height offset * @return the pixel height offset */ */ Loading Loading @@ -1047,15 +1049,22 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { // now process the content of the framelayout and dynamically create tabs for it. // now process the content of the framelayout and dynamically create tabs for it. final int count = content.getChildCount(); final int count = content.getChildCount(); if (count == 0) { throw new PostInflateException( "The FrameLayout for the TabHost has no content. Rendering failed.\n"); } // this must be called before addTab() so that the TabHost searches its TabWidget // this must be called before addTab() so that the TabHost searches its TabWidget // and FrameLayout. // and FrameLayout. tabHost.setup(); tabHost.setup(); if (count == 0) { // Create a dummy child to get a single tab TabSpec spec = tabHost.newTabSpec("tag").setIndicator("Tab Label", tabHost.getResources().getDrawable(android.R.drawable.ic_menu_info_details)) .setContent(new TabHost.TabContentFactory() { public View createTabContent(String tag) { return new LinearLayout(mContext); } }); tabHost.addTab(spec); return; } else { // for each child of the framelayout, add a new TabSpec // for each child of the framelayout, add a new TabSpec for (int i = 0 ; i < count ; i++) { for (int i = 0 ; i < count ; i++) { View child = content.getChildAt(i); View child = content.getChildAt(i); Loading @@ -1071,6 +1080,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { tabHost.addTab(tabHost.newTabSpec(tabSpec).setIndicator(name).setContent(id)); tabHost.addTab(tabHost.newTabSpec(tabSpec).setIndicator(name).setContent(id)); } } } } } /** /** Loading