如果我有這片與硬編碼字符串代碼「重要的新事件」:如何使用res/values/strings.xml中的字符串id而不是String或CharSequence?
public class MainActivity extends Activity {
private NotificationManager mNManager;
private static final int NOTIFY_ID = 1100;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String ns = Context.NOTIFICATION_SERVICE;
mNManager = (NotificationManager) getSystemService(ns);
final Notification msg = new Notification(R.drawable.ic_launcher,
"New event of importance",
System.currentTimeMillis());
但想將其移動到RES /價值/ string.xml文件,而不是:
<string name="new_event">New event of importance</string>
那麼如何在上面的構造函數中使用R.strings.new_event
(並且我知道構造函數已被棄用)?
還有一個問題請 - 爲什麼final
以上使用的關鍵字?