我无法在search: function(URL) {
var self = this;
$.ajax({
type: "GET",
dataType: 'json',
url: URL,
success: function(response){
self.showResults(response);
}.bind(this)
});
}
类的visibility
方法中为行布局设置bindview
。 (我得到空的空间)
码
CursorAdapter
请帮帮我。
答案 0 :(得分:0)
隐藏任何行项目都不是一个好主意。 最佳实践是实现可过滤,并避免将数据绑定到适配器中。
就像......
class ContactListAdapter extends CursorAdapter implements Filterable {
public ContactListAdapter(Context context, Cursor c) {
super(context, c);
mContent = context.getContentResolver();
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
final TextView view = (TextView) inflater.inflate(
android.R.layout.simple_dropdown_item_1line, parent, false);
view.setText(cursor.getString(COLUMN_DISPLAY_NAME));
return view;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
((TextView) view).setText(cursor.getString(COLUMN_DISPLAY_NAME));
}
@Override
public String convertToString(Cursor cursor) {
return cursor.getString(COLUMN_DISPLAY_NAME);
}
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
FilterQueryProvider filter = getFilterQueryProvider();
if (filter != null) {
return filter.runQuery(constraint);
}
Uri uri = Uri.withAppendedPath(
Contacts.CONTENT_FILTER_URI,
Uri.encode(constraint.toString()));
return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
private ContentResolver mContent;
}
public static final String[] CONTACT_PROJECTION = new String[] {
Contacts._ID,
Contacts.DISPLAY_NAME
};
private static final int COLUMN_DISPLAY_NAME = 1;
}
您可以使用已实施的方法过滤掉您的数据。
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
FilterQueryProvider filter = getFilterQueryProvider();
if (filter != null) {
return filter.runQuery(constraint);
}
Uri uri = Uri.withAppendedPath(
Contacts.CONTENT_FILTER_URI,
Uri.encode(constraint.toString()));
return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
快乐编码......