【发布时间】:2011-04-06 12:40:07
【问题描述】:
我有一个 AutoCompleteTextView 和一个 CursorAdapter。现在一切正常,您可以将它与android.R.layout.simple_dropdown_item_1line 一起使用,但是当您尝试为自定义布局充气时,Android 放弃了。
作品
@Override
public void bindView(View view, Context context, Cursor cursor) {
final String text = convertToString(cursor);
((TextView) view).setText(text);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view =
inflater.inflate(
android.R.layout.simple_dropdown_item_1line,
parent, false);
return view;
}
不起作用
@Override
public void bindView(View view, Context context, Cursor cursor) {
final String text = convertToString(cursor);
((TextView) findViewById(R.id.txtAutoCompleteText)).setText(text);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view =
inflater.inflate(
//android.R.layout.simple_dropdown_item_1line,
R.layout.auto_complete_item,
parent, false);
return view;
}
我知道有人已经问过类似的问题并被标记为已回答,但它不满足我的查询。
我有什么遗漏或者这是不可能的。
【问题讨论】:
标签: android android-layout autocompletetextview android-cursoradapter