AIOOB exception fix in TabWidget

Bug http://code.google.com/p/android/issues/detail?id=15005

The problem was not specific to the legacy theme. The code that first
measure the tab's width with no contraint was incorrectly using the
mImposedTabsWidth array which could not have the right size if a
child was added.

The first measure after a child is added should indeed crash. Could
be investigated. This fix is sure anyway.

Change-Id: I4c0594e92019aabc545619e874bdfd49ce69c90e
This commit is contained in:
Gilles Debunne
2011-02-25 14:34:20 -08:00
parent 7ad9eb69c4
commit cd59febcea

View File

@@ -174,8 +174,8 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener {
void measureHorizontal(int widthMeasureSpec, int heightMeasureSpec) {
// First, measure with no constraint
final int unspecifiedWidth = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
super.measureHorizontal(unspecifiedWidth, heightMeasureSpec);
mImposedTabsHeight = -1;
super.measureHorizontal(unspecifiedWidth, heightMeasureSpec);
int extraWidth = getMeasuredWidth() - MeasureSpec.getSize(widthMeasureSpec);
if (extraWidth > 0) {