我正在尝试进行自动完成,包括能够从firebase数据列表中搜索我搜索的选项
RelativeLayout无法转换为android.text.TextWatcher - 这是我的错误
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textAutoComplete|textAutoCorrect"
android:imeOptions="actionSearch"
android:hint="search here"
android:id="@+id/myAutoComplete"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/my_recycler_view"
/>
</RelativeLayout >
这是xml
Map<Integer, List<String>>
答案 0 :(得分:1)
根据我的理解,你需要像这样实现TextWatcher
txt.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});
您已经实现了textWatcher
更改此
txt.addTextChangedListener((TextWatcher) getView());
要
txt.addTextChangedListener(this);
更新
将layout_below
属性添加到您的recyclerview
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/my_recycler_view"
android:layout_below="@+id/myAutoComplete"/>