4列(_idを含む)でテーブルを作成しようとしていますが、3列(_idを含む)のテーブルを作成しても問題ありません。間違った番号の列を持つdbを作成します。
private static final String DATABASE_CREATE =
"create table collections (_id integer primary key autoincrement, "
+ "name text not null, description text not null, image integer not null);";
そして、私のonCreate:
私のテーブル定義は以下の通りです
私がデータにアクセスしていますどのように@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_CREATE);
}
:どんなに私がしようとするもの
public View getView(int position, View convertView, ViewGroup parent) {
cursor.moveToPosition(position);
LinearLayout ll = new LinearLayout(mContext);
ll.setOrientation(LinearLayout.VERTICAL);
ImageView i = new ImageView(mContext);
i.setImageResource(cursor.getInt(3)); //access to the image column
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setLayoutParams(new Gallery.LayoutParams(150, 150));
// The preferred Gallery item background
i.setBackgroundResource(mGalleryItemBackground);
ll.addView(i);
TextView tv = new TextView(ll.getContext());
tv.setTag(mText[position]);
tv.setText(cursor.getString(1)); //access to the name column
tv.setLayoutParams(new Gallery.LayoutParams(48, 48));
ll.addView(tv);
return ll;
}
を、それはテーブルの外に列のイメージを残し続ける...私が得る助けに感謝します。
'_image'という列に名前を付けてみましたか? –
さて、私は同じ問題を抱えています。http://stackoverflow.com/questions/8656146/column-not-created-in-sqlite3-tableを参照してください。理由を見つけたら教えてください。私は自分のコードとカラム名を何度も書き直しましたが、何も動作していないようです。それは幽霊の列のようなものです。 –
イメージの列名を別のものに変更して試してください。 – kosa