私のアンドロイドプロジェクトでは、カメラのスナップショットとSQLiteデータベースの説明が保存されています。今私はすべてのそれらの画像と1つずつ説明を取得し、私が作成したXMLレイアウトでそれらを表示したいと思います。ここSQLite DBに保存されたすべての画像をレイアウトに取り込む方法は?
は私のxmlレイアウトです:私はseperatlyコードスニペットを以下試してみました
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/showTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Data" />
<ImageView
android:id="@+id/showIv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/marker_default"
/>"
</LinearLayout>
</LinearLayout>
、
String[] columns = new String[]{"_id", "name","description","image"};
Cursor c = myDb.query(DATABASE_TABLE, columns, null, null, null, null, null);
if (c.getCount()>0){
c.moveToNext();
byte[] data = c.getBlob(c.getColumnIndex("image"));
return data;
}else{
return null;
// iは、ビットマップにバイト配列に変換し、レイアウト
String result = "";
int iname= c.getColumnIndex("name");
int ides= c.getColumnIndex("description");
TextView tv = (TextView) findViewById(R.id.showTv);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
result += c.getString(iname) + c.getString(ides);
}
return result;
上に表示しました
しかし、私は、すべてのデータについて画像と説明を一緒にしたいと思っています。
私はすべての画像と説明を1つずつ提案してください。
ありがとう...
おかげでたくさんのサムエルは、Androidに初心者をIMと私は3日間の適切な例を検索してきました。あなたのリンクにもう一度感謝します。 – Manoj