Is there any way to create an inner class in the auto-generated R file?
Right now R file looks like this:
public static final class id {
public static final int button1=0x7f020000;
public static final int button2=0x7f020001;
public static final int text1=0x7f020002;
}
And to access it, you should type
R.id.button1
What do I want to get it something like this:
public static final class id {
public static final class activity1 {
public static final int button1=0x7f020000;
}
public static final int button1=0x7f020001;
}
So I can access it with
R.id.activity1.button1
It is possible to manually edit the file, but that’s not the way I’m looking for
Update: I need this because my current project consists of around 20 activities, with 5-30 widgets on each of them. I’m skipping a lot of ids(mostly for buttons and layout), but still it’s not comfortable to type something like
AcEventListToolbarUserImageView
(AcEventList – name of activity, Toolbar – frame, UserImageView – user picture)
Update 2: partial solution is:
in activity layout xml
<TextView android:id="@+id_ActivityName/WidgetName" />
in the java code it will be:
R.id_ActivityName.WidgetName
Pros:
see all your activity list after typing “R.id_”;
see all widget ids for the activity you need by typing “R.id_ActivityYouNeed.”
The auto-generation of the R.java file is purely there as a mechanism to allow you to easily reference the contents of your
reshierarchy from your code. As such, you cannot create sub-hierarchies.The simple solution is to add context to your item names instead. For example, use
@+id/Activity1_button1, and you can access this asR.id.Activity1_button1.