for example:
public final class R {
public static final class raw {
public static final int yuri=0x7f040000;
}
}
How can I get the resource by its name? Without using R.raw.yuri = (int)
android:text="@string/hello" /> String string = getString (R. string. hello); You can use either getString(int) or getText(int) to retrieve a string.
The Android resource system keeps track of all non-code assets associated with an application. You can use this class to access your application's resources. You can generally acquire the Resources instance associated with your application with getResources() .
You can find strings. xml file inside res folder under values as shown below.
getResources().getIdentifier( "yuri" , "raw" , getPackageName() );
I found this to be extremely slow. I stripped it out of my whole project after doing some profiling and used int[]
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With