1
我有一个自定义的CursorAdapter,我正在使用它来相应地自定义项目布局和样式,如下面的代码所示。我的问题是,有时错款式信息提供,即使从数据库中传来的数据是正确的(所以下面的例子中我会得到isEvent == true
但它会仿佛isEvent == false
去到风格。android:styling来自自定义CursorAdapter的ListView项目
这是一个已知的错误?我做错了什么或有什么我可以做,这将解决这个问题?
private class EventAdapter extends CursorAdapter {
public EventAdapter(Context context) {
super(context, null);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return getLayoutInflater().inflate(R.layout.event_view_list_item, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
final boolean isEvent = cursor.getInt(EventQuery.IS_EVENT) == Event.EVENT;
final String eventName = cursor.getString(EventQuery.NAME);
final TextView eventNameView = (TextView) view.findViewById(R.id.event_name);
if (isEvent) {
eventNameView.setText(eventName);
view.findViewById(R.id.arrow).setVisibility(View.VISIBLE);
view.findViewById(R.id.in_play_icon).setVisibility(View.GONE);
} else {
eventNameView.setText(cursor.getString(EventQuery.NAME));
}
}
}
嗨,你是如何设法阻止Android回收视图?我一直坚持这问题太长了... – JonWells 2011-11-22 14:49:25
看看这个http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html – Martyn 2011-11-22 16:05:39
和这个http: //www.screaming-penguin.com/node/7767 – Martyn 2011-11-22 16:06:03