1

Currently I have a class called CustomizedGallery that extends the default Gallery. I include it in my XML layout files like this:

      <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_marginLeft="80px"
    android:layout_marginTop="0px"
    android:layout_width="869px"
    android:layout_height="605px"
    android:background="#000000"
    android:orientation="horizontal" >

    <com.my.path.here.CustomizedGallery
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="864px"
        android:layout_height="600px"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:id="@+id/gallery" />
</RelativeLayout>

The problem is that, every time I change my package name (com.my.path.here), I have to manually edit the XMLs as well (because they don't get updated as the .java files). Is there a way that I can include my custum gallery class in the XML such as I don't need to edit the package name every time in the XMLs that use my custom class??

PS: You might wonder why the heck I change the package names so often. The reason is because I build very similar apps for the same client, so, I need to change the package name every time so the slightly modified app can be installed in the same device.

Thank you in advance!

  • When using the `Rename Application Package` option, references in xml files do get updated too. – K-ballo May 29 '12 at 02:15
  • I was getting an error trying to do that. I have reimported my project and now that option works. Such a simple solution! I guess the problem was in the project build, not in that option itself. Thanks K-ballo! – Bitcoin Cash - ADA enthusiast May 29 '12 at 02:27
  • Although I was wondering if there was a "XML namespace" solution or something like that... you know, a more elegant way to do that, instead of hardcode the package name in the XML file. – Bitcoin Cash - ADA enthusiast May 29 '12 at 02:29
  • You can use a `LayoutInflater.Factory` and do the mapping yourself... – K-ballo May 29 '12 at 02:32
  • if you reuse the same code in different projects you may want to have it in some kind of library that you just add to all of your project. this way you won't have the namespace problem and the code is easier to maintain as well (espacially fixing bugs - duplicate code is very bad style) – AxelTheGerman May 29 '12 at 05:42
  • K-ballo, you can post your first answer for me to accept it. I think that is the best solution. Axel, I don't think you understood my question. The application is the same. Just very feel things change (like, 1% of the application). – Bitcoin Cash - ADA enthusiast May 29 '12 at 21:28

0 Answers0