Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
string.xml から文字列を取得するにはどうすればよいですか?
私が試したこと
getString(R.string.id);
context.getString(R.string.id);
getResources().getString(R.string.id);
そして何も機能しません。
これを実行しようとしているクラスは、これらのメソッドを可視化するために、Activity (または Application) を拡張するか、Activity/Application コンテキストを渡す必要があります。そうでなければ、あなたがしていることは正しいです。
最後のものは、アクティビティを拡張するクラスにいる限り機能するはずです