0

I am a newbie for java and android.

As we know a Textview with id R.Id.text1 show in xml file

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"   <-----------HERE
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:paddingLeft="5dip"
    android:singleLine="true"

Is there a way to get R.Id.text1 's text1 programmatically?

Your comment welcome

arachide
  • 8,006
  • 18
  • 71
  • 134
  • That would actually be `android.R.id.text1`. Aside from that, what do you want, exactly? The string `text1` from the numerical ID? – Mike M. May 24 '20 at 02:48
  • yes The string text1 from the numerical ID – arachide May 24 '20 at 02:50
  • You can use the `Resources#getResourceEntryName(int)` method for that. – Mike M. May 24 '20 at 02:51
  • As an example, if you're in an `Activity`, it would be something like `String name = getResources().getResourceEntryName(android.R.id.text1);`. The value in `name` would then be `text1`. – Mike M. May 24 '20 at 02:58
  • Well, that's actually kind of the reverse of what I was describing. Are you sure that's what you're looking for? If not, let me know, and I'll change the linked duplicate to one with solutions for getting the string `text1` from the numerical ID; e.g., https://stackoverflow.com/q/10137692. Cheers! – Mike M. May 24 '20 at 03:17

0 Answers0