I want to learn RXjava for android, so I have done the following:
1) I have downloaded the jar file of rxandroid-0.24.jar , rxandroid-framework-0.24.jar
2) added files to libs folder in android studio
3) add lib dependency to android studio, please check following screenshot:
4) tried some code in my fragment and it doesn't seem to see rxandroid, please check following code:
import rx.Observable;
public class AboutFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Observable.from("one","two","three","four","five")
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.sobscribe(/* an Observer */);
}
I am using this tutorial https://github.com/ReactiveX/RxJava/wiki/The-RxJava-Android-Module
Can anyone please help and tell me what is missing here?
You're missing the import for the Android schedulers; they're in a different package to the rest of RxJava:
import rx.android.schedulers.AndroidSchedulers;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.