Force the id of TabWidget to be android:id/tabs
This commit is contained in:
@@ -722,11 +722,9 @@ public final class DescriptorsUtils {
|
|||||||
fill ? LayoutConstants.VALUE_FILL_PARENT : LayoutConstants.VALUE_WRAP_CONTENT,
|
fill ? LayoutConstants.VALUE_FILL_PARENT : LayoutConstants.VALUE_WRAP_CONTENT,
|
||||||
false /* override */);
|
false /* override */);
|
||||||
|
|
||||||
String widget_id = getFreeWidgetId(ui_node.getUiRoot(),
|
String widget_id = getFreeWidgetId(ui_node);
|
||||||
new Object[] { ui_node.getDescriptor().getXmlLocalName(), null, null, null });
|
|
||||||
if (widget_id != null) {
|
if (widget_id != null) {
|
||||||
ui_node.setAttributeValue(LayoutConstants.ATTR_ID, "@+id/" + widget_id, //$NON-NLS-1$
|
ui_node.setAttributeValue(LayoutConstants.ATTR_ID, widget_id, false /* override */);
|
||||||
false /* override */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_node.setAttributeValue(LayoutConstants.ATTR_TEXT, widget_id, false /*override*/);
|
ui_node.setAttributeValue(LayoutConstants.ATTR_TEXT, widget_id, false /*override*/);
|
||||||
@@ -752,13 +750,20 @@ public final class DescriptorsUtils {
|
|||||||
/**
|
/**
|
||||||
* Given a UI root node, returns the first available id that matches the
|
* Given a UI root node, returns the first available id that matches the
|
||||||
* pattern "prefix%02d".
|
* pattern "prefix%02d".
|
||||||
|
* <p/>TabWidget is a special case and the method will always return "@android:id/tabs".
|
||||||
*
|
*
|
||||||
* @param uiNode The UI node that gives the prefix to match.
|
* @param uiNode The UI node that gives the prefix to match.
|
||||||
* @return A suitable generated id
|
* @return A suitable generated id in the attribute form needed by the XML id tag
|
||||||
|
* (e.g. "@+id/something")
|
||||||
*/
|
*/
|
||||||
public static String getFreeWidgetId(UiElementNode uiNode) {
|
public static String getFreeWidgetId(UiElementNode uiNode) {
|
||||||
return getFreeWidgetId(uiNode.getUiRoot(),
|
String name = uiNode.getDescriptor().getXmlLocalName();
|
||||||
new Object[] { uiNode.getDescriptor().getXmlLocalName(), null, null, null });
|
if ("TabWidget".equals(name)) { //$NON-NLS-1$
|
||||||
|
return "@android:id/tabs"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
return "@+id/" + getFreeWidgetId(uiNode.getUiRoot(), //$NON-NLS-1$
|
||||||
|
new Object[] { name, null, null, null });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user