1

Can I get this string in code?

GetId() returns an int?

enter image description here

EDIT:

If not, is there a way I can assign my textboxes a tag each, which is a string, and then return this in code?

4

2 回答 2

1

You are looking for the resource name:

getResources().getResourceEntryName(intresid); 

If you want the resource name include package name then use:

getResources().getResourceName(intresid);
于 2013-03-30T12:18:42.457 回答
1

Can I get this string in code?

No. You can get only ID of resource. Reason is because your R.class storing all resources as

public static final int fields

Your R.java can looks similar like this:

public static final class id {
        public static final int DataHallTextField=0x7f09000a;
}

Update:

If not, is there a way I can assign my textboxes a tag each, which is a string, and then return this in code?

So i think you are looking for this:

String name = getResources().getResourceEntryName(R.id.DataHallTextField);

If you want also package you can use

String name = getResources().getResourceName(R.id.DataHallTextField);
于 2013-03-30T12:19:16.130 回答