Wednesday, August 24, 2011

[Android] resource string-ek kiolvasasa

Innen

-In a Layout XML:
android:text="@string/resource_name"

-In an Activity:
this.getString(R.string.resource_name);

-In an area of the program in which you have access to a Context or Application, such as a ListAdapter:
context.getString(R.string.resource_name);
application.getString(R.string.resource_name);

In case there is not a Context or Activity handy:
final Resources r = Resources.getSystem();
r.getString(android.R.string.resource_name);
vagy:
String r = getResources().getString(R.string.resource_name);

No comments: