6 Ekim 2015 Salı

R Dosyası

Giriş
R dosyası derleyici tarafından oluşturulur. Dosyanın için int sabitlerle doludur.

Bir çok sınıf R dosyası için bir metod daha tanımlar. Örneğin TextView sınıfı hem
public final void setText(CharSequence text)
hem de R dosyası ile beraber kullanabilmek için
public final void setText(int resid)
şeklinde iki metod sunar.

String
R dosyasındaki string sabitin gerçek değerine şöyle erişiriz.
return getResources().getString(resId);
Hatta Context sınıfı bize şöyle bir metod sunar.
 /**
 * Return a localized string from the application's package's
 * default string table.
 *
 * @param resId Resource id for the string
 */
public final String getString(int resId) {
    return getResources().getString(resId);
}