[android-developers] Re: GK:How to give conditions in android XMLs
Yes, and XSLT can be easily invoked from an ant script.
As a sample, here's a script that removes an Admob view from a layout:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<!-- Any parameters you may need to pass to your script should be
declared like this. -->
<xsl:param name="BUILDTYPE"/>
<!-- Rules for anything you may want to modify from the input -->
<xsl:template match="com.admob.android.ads.AdView">
<xsl:choose>
<xsl:when test="$BUILDTYPE = 'PRO'">
<xsl:comment>An innocuous empty replacement for the
ad.</xsl:comment>
<RelativeLayout
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/labelBackground"
/>
</xsl:when>
<xsl:otherwise>
<!-- Otherwise, just invoke whatever rules would
otherwise run,
- normally the default rule below. -->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Identity transform by default: everything else goes through
this rule.
- You will always need this. -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
And an ant task to invoke it:
<xslt in='${loc.project}/AndroidManifest.xml'
out='${loc.project.build.PRO}/AndroidManifest.xml'
style='configureManifest.xsl'
force='true'>
<param name='BUILDTYPE' expression="PRO"/>
</xslt>
On Oct 26, 7:06 pm, Frank Weiss <fewe...@gmail.com> wrote:
> Although I'm not sure I understand your problem completely, I can offer
> another solution: XSLT. Using Xalan's multiple output documents make this
> relatively easy.
>
> Are you thinking of creating an .apk for each carrier from the same code
> base? That's another can of worms. However, perhaps using ADT library
> project you can share the common behavioral code and each .apk project only
> needs to provide the carrier-specifc data and resources.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home