当我使用onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)时,问题是oncreateview类中不存在Service

public class FloatingViewService extends Service{
    CircleMenu circleMenu;
    public FloatingViewService() {
}

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onCreate() {
    super.onCreate();
    //Inflate the floating view layout we created
    mFloatingView = LayoutInflater
       .from(this)
       .inflate(R.layout.layout_floating_widget, null);
    circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
}

最佳答案

尝试将最后一行更改为:

circleMenu = (CircleMenu) mFloatingView.findViewById(R.id.circle_menu);

09-12 18:24