1

我正在尝试在我的数据库列表中显示活动中的所有产品。我使用了 NewView 和 BindView。我没有向我展示所有元素(条形码、格式、标题、价格),而是只看到最后一个,价格。任何解决方案表示赞赏!:) 这是代码的一部分:

        Cursor cursor = db.rawQuery("select * from " + PRODUCT_TABLE, null);

        setListAdapter(new CursorAdapter(this, cursor, true) {

        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent){

            TextView textView = new TextView(ProdottiSelectionActivity.this);
            textView.setText(cursor.getString(cursor.getColumnIndex("barcode")));
            textView.setText(cursor.getString(cursor.getColumnIndex("format")));
            textView.setText(cursor.getString(cursor.getColumnIndex("title")));
            textView.setText(cursor.getString(cursor.getColumnIndex("price")));
            return textView;
        }

        @Override
        public void bindView (View view, Context context, Cursor cursor){

            TextView textView = (TextView) view;
            textView.setText(cursor.getString(cursor.getColumnIndex("barcode")));
            textView.setText(cursor.getString(cursor.getColumnIndex("format")));
            textView.setText(cursor.getString(cursor.getColumnIndex("title")));
            textView.setText(cursor.getString(cursor.getColumnIndex("price")));

            }
        });
4

1 回答 1

1

使用 textView.append() 而不是 setText

于 2012-06-11T10:08:08.997 回答