RxBindings For Spinner?

百般思念 提交于 2019-12-04 00:43:15

The items in the Spinner come from the Adapter associated with this view.

See the Spinners guide.

To define the selection event handler for a spinner, implement the AdapterView.OnItemSelectedListener interface and the corresponding onItemSelected() callback method. For example, here's an implementation of the interface in an Activity:

Documentation: https://developer.android.com/guide/topics/ui/controls/spinner.html

RxBinding Documentation: https://github.com/JakeWharton/RxBinding/blob/31e02dcaca426e2ce440093b501e1a28fe1461f6/rxbinding/src/androidTest/java/com/jakewharton/rxbinding2/widget/RxAdapterViewTest.java

After searching for Spinner in GitHub-Repository, I found an example for Spinner:

RxAdapterView.itemSelections(spinner)
    .subscribeOn(AndroidSchedulers.mainThread())
    .subscribe(integer -> {
        Log.v("spinner", integer.toString());
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!