为此,我有一个 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 方法,只有第一个值会出现几次有人可以帮助我吗?谢谢