gpt4 book ai didi

java - SimpleCursorAdapter 未定义?

转载 作者:行者123 更新时间:2023-12-01 19:16:40 25 4
gpt4 key购买 nike

下面是让我悲伤的代码示例。如果我将 simpleCursorAdapter 放在 textchangedlistener 之外,但不在我不断收到消息中,则 simpleCursorAdapter 可以工作

The constructor SimpleCursorAdapter(new TextWatcher(){}, int, Cursor, String, int, null) is undefined

txt.addTextChangedListener(new TextWatcher() {

public void onTextChanged(CharSequence s, int start, int before, int count) {
//onTextChanged
}

public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//beforeTextChanged

}

public void afterTextChanged(Editable s) {
//afterTextChanged
typedText = s.toString();

Cursor cur = db.rawQuery("SELECT * FROM " +
DB_TABLE +" where field LIKE '%" + typedText + "%'" , null);
String displayFields = "field";
int displayViews = R.id.bmark_visits;
setListAdapter(new SimpleCursorAdapter(this,
R.layout.testlist, cur,
displayFields, displayViews, null
));
}
});

最佳答案

SimpleCursorAdapter 构造函数的第一个参数应该是您的 Activity 。但是,在匿名 TextWatcher 内部类中,this 是匿名 TextWatcher 内部类的实例。请改用 MyActivity.this,其中 MyActivity 是您的 Activity 的名称。

关于java - SimpleCursorAdapter 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6325194/

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