gpt4 book ai didi

android - 微调器的 RxBindings?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:33:33 27 4
gpt4 key购买 nike

我是新的 android 和 rxjava。我经历过很多使用 rxbindings 监听事件的例子。比如这个

 RxView.clicks(b).subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
// do some work here
}
});

RxTextView.textChanges(name)
.subscribe(new Action1<String>() {
@Override
public void call(String value) {
// do some work with the updated text
}
});

现在我正在尝试为 android spinner 做同样的事情。我想听 itemselected 事件。谁能帮忙?

最佳答案

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:

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

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

在GitHub-Repository中搜索Spinner后,找到了一个Spinner的例子:

RxAdapterView.itemSelections(spinner)
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(integer -> {
Log.v("spinner", integer.toString());
});

关于android - 微调器的 RxBindings?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43446747/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com