我正在学习RxJava以下文章:http://blog.danlew.net/2014/09/15/grokking-rxjava-part-1/
第一个示例使用RxJava打印字符串。我做了一点改变。请参阅以下代码。
Observable myObservable = Observable.create(
new Observable.OnSubscribe() {
@Override
public void call(Subscriber<? super String> o) {
o.onNext("hello world");
o.onCompleted();
}
}
);
Subscriber mySubscriber = new Subscriber() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(String s) {
Toast.makeText(mActivity,s,Toast.LENGTH_SHORT).show();
}
}
让它展示吐司。
首先,Android Studio生成的代码在Observable中调用(Object o),在Subscriber中调用onNext(Object o)
然后我按照文章改变它,改变&#34;对象o&#34;到&#34;订阅者o&#34;
但Android Studio通知我&#34; Class 'Anonymous class derived from OnSubscribe' must be either declared abstract or implement abstract method 'call(T)' in Action1
&#34;在订阅者o。和&#34; method does not override method from it's superclass
&#34;在onNext()
我做错了什么?