내 안드로이드 프로젝트에서 SQLite 데이터베이스의 일부 설명과 함께 카메라 스냅 샷을 저장했습니다. 이제는 모든 이미지와 설명을 하나씩 검색하여 내가 만든 xml 레이아웃으로 보려고합니다. 여기 SQLite db에 저장된 모든 이미지를 레이아웃으로 가져 오는 방법은 무엇입니까?
내 XML 레이아웃입니다 :<?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;
// 내가 비트 맵 바이트 배열을 변환 및 레이아웃에 표시
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;
그러나 나는 모든 데이터에 대해 이미지와 설명을 함께 얻고 싶다.
하나씩 모든 이미지와 설명에 대한 방법을 제안 해주세요.
감사와 나는 3 일 동안 적절한 예를 검색했습니다 :
은 한 번보세요. 귀하의 링크에 다시 한 번 감사드립니다. – Manoj