현재 사진 촬영 후, 저장하면 path(/img/*.jpg)만 string 으로 받아와 몇가지 정보를 더 입력한 후에 DB에 저장되도록 하였습니다.
테이블 구조는
--------------------------------------------
name | category | opt1 | opt2 | path |
--------------------------------------------
이런 구조로 되어 있습니다.
이 전부를 리스트로 뿌려주는데, String 만 뿌려주는 것은 simple list adapter 이용해서 성공 하였는데요.
제가 하고 싶은 것은
path에 저장되어 있는 img의 썸네일과 , DB에 있는 몇몇 필드만 꺼내어 보여주고 싶습니다.
---------------------------------
썸네일 + name, category
---------------------------------
썸네일 + name, category
---------------------------------
이런 식으로요.
지금
그냥 simple list adapter 에서 해쉬맵 이용한 걸로 바꾸고 있는데 cursor가 계속 바운더리 밖에 있다고 (인덱스가 -1이라며)
exception 띄워주고 죽어버립니다.
솔직히 해쉬맵에 대해서 50%쯤 이해한 상황이구요 ㅜ path에서 img의 thumbnail로 접근하는 방법은 몰라서 그냥 drawable에 있는 icon 주소를 사용하고 있습니다. 어떻게 해야할지 감이 전혀 안오네요 ㅜㅜ 조언 좀 부탁드립니다. ㅜㅜ
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new DbAdapter(this); mDbHelper.open();// Database 열기 mCursor = mDbHelper.fetchAllRows(); startManagingCursor(mCursor);
ArrayList<clothItem> Cloth = new ArrayList<clothItem>(); List<HashMap<String, Object>> mList = new ArrayList<HashMap<String, Object>>(); int[] imgSrc = getResources().getIntArray(R.array.img); if(mCursor.isFirst()){ for (int i = 0; i < mCursor.getCount(); i++) {
HashMap<String, Object> item = new HashMap<String, Object>(); item.put("ca1", mCursor.getString(1)); item.put("ca2", mCursor.getString(2)); item.put("ca3", imgSrc[1]); mList.add(item); mCursor.moveToNext(); } } else Log.i(TAG, "에러남"); SimpleCursorAdapter sAdapter = new SimpleCursorAdapter(this, R.layout.collection, mCursor, new String[] { "ca1", "ca2", "ca3"}, new int[] { R.id.text1, R.id.text2, R.id.img}); setListAdapter(sAdapter); } class clothItem { String name; String category; //String season; int img; public clothItem(String name, String category, int img) { super(); this.name = name; this.category = category; //this.season = season; this.img = img; } } }