Android通知';无法解析方法';build()';从ABS片段

Android通知';无法解析方法';build()';从ABS片段,android,android-fragments,actionbarsherlock,android-notifications,Android,Android Fragments,Actionbarsherlock,Android Notifications,我试图在ActionBarSherlock布局中显示来自片段的基本通知。我和Android开发者页面上的一样好,但我在最后一行遇到了错误“无法解析方法”build()。我已经导入了android.support.v4.app.NotificationCompat和.app.NotificationManager public void createNotification(){ NotificationManager mNotificationManager = (Notificati

我试图在ActionBarSherlock布局中显示来自片段的基本通知。我和Android开发者页面上的一样好,但我在最后一行遇到了错误“无法解析方法”build()。我已经导入了
android.support.v4.app.NotificationCompat
.app.NotificationManager

public void createNotification(){

    NotificationManager mNotificationManager = (NotificationManager)getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getActivity());
    mBuilder.setSmallIcon(R.drawable.icon);
    mBuilder.setContentTitle("Title");
    mBuilder.setContentText("Text");
    mBuilder.setTicker("Ticker");
    mNotificationManager.notify(1,mBuilder.build());
}

如果我将最后一行更改为
mNotificationManager.notify(1,mBuilder.getNotification())它可以工作。为什么会这样?

我在build()和getNotification()中都使用了它。 仅供参考,Notification.Builder.build()是API级别16,因此请检查您的目标。 还要检查导入和生成路径,并清理项目。如果问题仍然存在,请尝试libs中的另一个android-support-v4.jar,因为它可能已损坏


希望这能有所帮助。

谢谢,我将尝试您的建议,我已设置为API级别16。我在使用ActionBarSherlock时更新了这个问题,以防万一会有所不同。