이미지를 String 형으로 파일명을 가져와서, DB에 저장시킨 뒤 ,
뿌려줄때, 가져와서 이미지를 뿌려주는 방법으로 처리하려 합니다.
일단 파일명을 저장시키는 부분이
file.add(0,"q1");
file.add(1,"q2");
file.add(2,"s0_0");
file.add(3,"s0_1");
for(int i = 0; i < file.size(); i++){
SQLiteDb.DbCreate(file.get(i));
}
이렇게 저장을 하구..
가져오는 부분은
SQLiteDatabase sdb = SQLiteDb.dbHelper.getReadableDatabase();
Cursor c = sdb.query(Colms.TABLE_NAME,
new String[] { "resid" } , null, null, null, null,
null);
c.moveToPosition(count);
String resid = c.getString(0);
Log.e("resid",resid);
int imageResource = context.getResources().getIdentifier(resid , "drawable", context.getPackageName());
gv = new GameView(mContext,/*R.drawable.q1*/imageResource,3);
sdb.close();
이렇게 되어있구요..
로그를 찍어봤는데.. 저장도 다 되고.. 그런것 같던데..
ViewFlipper 사용시 일단 한쪽만 만들어 봤는데,
오른쪽으로 드래그 시 -> 뷰 생성 -> 다음 뷰 보기 이렇게 하려고 합니다.
그런데
flipper = (ViewFlipper)findViewById(R.id.flipper);
flipper.addView(new 뷰이름(this,0), 0);
플리퍼 초기화를 하고
if((downX - upX) > 70){
/*if(count >= fv.getGv().getBackCount()){
count = fv.getGv().getBackCount();
}
else{*/
count ++;
Log.e("count",""+count);
flipper.addView(new FlippView(this,count),count);
flipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_in));
flipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_out));
flipper.showNext();
flipper.removeViewAt(0);
flipper.destroyDrawingCache();
//}
}
이런식으로 조건을 줘서 처리하면
flipper.addView(new FlippView(this,count),count);
이부분에서 java.lang.IndexOutOfBoundsException: index=2 count=1
이 오류가 납니다...
정확히 어떤문제인지 모르겠습니다 ㅠㅠ 도와주세요 ㅠㅠ