2012-01-10 5 views
0

내 안드로이드 프로젝트에서 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; 

그러나 나는 모든 데이터에 대해 이미지와 설명을 함께 얻고 싶다.
하나씩 모든 이미지와 설명에 대한 방법을 제안 해주세요.

은 당신이 만든

답변

0

배치는 하나 개 이상의 이미지를 지원하지 않습니다 ... 감사합니다. 하나의 ImageView 만 있기 때문에. 당신이 많은 이미지 조작을 원한다면 않는 한. 따라서 사용자는 자신의 필요에 맞는보기를 선택해야합니다. Gallery 위젯이나 ListView 위젯을 살펴 보겠습니다. 그런 다음 데이터베이스의 데이터를 갤러리 또는 목록보기 위젯으로 조정하는 커서 어댑터를 만들어야합니다. 많은 사무엘, 안드로이드 초보자 메신저 listview with sqllite

+0

감사와 나는 3 일 동안 적절한 예를 검색했습니다 :

은 한 번보세요. 귀하의 링크에 다시 한 번 감사드립니다. – Manoj

관련 문제