我正在尝试将TextView的字符串值显示为charSequence

时间:2012-10-09 09:18:01

标签: android notifications

这是我的代码:

MyNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    int icon = R.drawable.ic_launcher;
    String tickerText = "Hello";
    Notification notification = new Notification(icon, tickerText, System.currentTimeMillis());

    String contentTitle = GetString(R.id.title);

    MyI = new Intent(getApplicationContext(), LyceumWebNotification.class);

    MyPI = PendingIntent.getActivity(getApplicationContext(), 0, MyI, 0);
    notification.setLatestEventInfo(getApplicationContext(), "Hello" , "Title: " + contentTitle, MyPI); 
    MyNM.notify(NOTIFICATION_ID, notification);


public String GetString(int id){
return ((TextView)this.findViewById(id)).getText().toString();

}

可以获取TextView的数据并显示为通知的Charsequence吗?

1 个答案:

答案 0 :(得分:0)

getText()已经返回CharSequence。不要将其转换为String