Wednesday, June 29, 2011

Re: [android-developers] Different resources, one xml file?

I achieved something similar by subclassing a layout (in my case it was RelativeLayout) and specifying custom XML attributes.

Then when I used it in my xml files I just specified that I wanted my custom layout view and specified my custom attributes to make them slightly different (i.e. different background images, text, etc...)

Not sure if the use case will work for you, but it worked like a charm in my case.

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Mon, Jun 27, 2011 at 12:48 AM, TreKing <trekingapp@gmail.com> wrote:
On Fri, Jun 24, 2011 at 4:00 AM, muckwarrior <muckwarrior@gmail.com> wrote:
Is there an easy way to do this without duplicating code?

protected void onCreate(Bundle bundle)
{
 setContentView(R.layout.my_single_layout);
 setCustomButtonImageBasedOnSubject();
 setCustomBackgroundImageBasedOnSubject();
}

Now implement those two functions.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices

--
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

--
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

No comments:

Post a Comment