안녕하세요 데이터 베이스를 이용해서 스케줄 괄리 프로그램을 만들고 있는데요.
날짜에 맞는 데이터 뽑아 오는거랑
GridView안에 생성된 클래스의 버튼의 이벤트 처리 관련에서 이렇게 글을 올립니다.
db=adb.getWritableDatabase();
Cursor cursor;
////////////////////////////////////////////////////////////////////////여기
cursor = db.rawQuery("SELECT PICTURE, DATE, WORK FROM aschedule WHERE aschedule MATCH '2011-06-30'", null); <-이부분
while(cursor.moveToNext()){
String time1,date1;
date1=cursor.getString(1).substring(0,cursor.getString(1).indexOf(" "));
time1=cursor.getString(1).substring((cursor.getString(1).indexOf(" ")+1),cursor.getString(1).length());
awork= new MyItem(cursor.getInt(0),date1,time1,cursor.getString(2));
workItem.add(awork);
workAdapter= new MyListAdapter(Successit.this, R.layout.listofplan, workItem);
workList=(ListView)findViewById(R.id.inputlist);
workList.setAdapter(workAdapter);
}
cursor.close();
adb.close();
위에 보시면 쿼리 부분이 있는데 Where 절을 이용해서 aschedule 에 MATCH '2011-06-30' 이용해서 조회를 할려고 하는데 오류가 나더라고요 어떻게 쿼리를 해야 하는지 궁금 합니다.
두번째는
class MyListAdapter extends BaseAdapter{
Context maincon;
LayoutInflater Inflater;
ArrayList<MyItem> arSrc;
int layout;
public MyListAdapter(Context context, int alayout, ArrayList<MyItem> aarSrc){
maincon = context;
Inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
arSrc = aarSrc;
layout = alayout;
}
public int getCount(){
return arSrc.size();
}
public String getItem(int position){
return arSrc.get(position).Date;
}
public long getItemId(int position){
return position;
}
public View getView(final int position, View convertView, final ViewGroup parent){
if(convertView == null){
convertView = Inflater.inflate(layout, parent,false);
}
ImageView imgofcheck = (ImageView)convertView.findViewById(R.id.imgoflist);
imgofcheck.setImageResource(arSrc.get(position).Icon);
TextView txtofdate = (TextView)convertView.findViewById(R.id.dateoflist);
txtofdate.setText(arSrc.get(position).Date);
TextView txtoftime = (TextView)convertView.findViewById(R.id.timeoflist);
txtoftime.setText(arSrc.get(position).Time);
TextView txtofwork = (TextView)convertView.findViewById(R.id.workoflist);
txtofwork.setText(arSrc.get(position).Work);
Button btn = (Button)convertView.findViewById(R.id.deletoflist);
btn.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
arSrc.remove(position);
notifyDataSetChanged();
}
});
return convertView;
}
}
이 클래스가 생성되어 GridView 안의 리스트로 들어가게 되는데 그리드 객체가 하나가 선택이 아니라 자기 자신의 버튼을 클릭 당했을때 그내용을 바탕으로 데이터베이스에서 삭제를 할려고 하는데 이벤트 처리를 어떻게 해야 하는지 모르겠습니다 ㅠㅠ 도와주세요




1번) like 이용하시면 되겠네요.
2번) onItemClickListener 이용하시면 됩니다.