我有一个GridView和一个SimpleCursorAdapter。代码看起来像这样
GridView myGridView = (GridView) this.freePassDialog.findViewById(R.id.gridview_buttons);
String[] column = { "name", "type" };
int[] viewIds = new int[] { R.id.name_button, R.id.type_button };
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(this.parent, R.layout.row_free_pass_buttons, cursor, column, viewIds) {
/**
* {@inheritDoc}
* @see android.widget.SimpleCursorAdapter#bindView(android.view.View, android.content.Context, android.database.Cursor)
*/
@Override
public void bindView(View view, Context context, Cursor cursor) {
String freePassName = cursor.getString(cursor.getColumnIndex("name"));
String freePassType = cursor.getString(cursor.getColumnIndex("type"));
Button freePassBtn = (Button) view.findViewById(R.id.pass_name_button);
if (PaymentMethodType.SMARTCARD_PASS == PaymentMethodType.valueOf(freePassType)) {
freePassBtn.setVisibility(View.GONE);
} else {
freePassBtn.setVisibility(View.VISIBLE);
}
super.bindView(view, context, cursor);
}
};
myGridView.setAdapter(myCursorAdapter);
光标有4个值,但对我来说,如果我将一些记录器放入BindView方法,只有第一个值会多次出现 有人能帮我吗? 感谢
答案 0 :(得分:0)
我发现您发布的代码没有任何问题......虽然我能找到的这类事情的每个示例都会显示覆盖newView
和bindView
。也许你应该实现newView
覆盖?
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(layout, parent, false);
return v;
}