안드로이드 개발 질문/답변
(글 수 45,052)
Cursor Adapter 를 사용하여 다이얼로드 안에 있는 리스트뷰에 아이템 추가를 하려고 합니다.
그리드뷰에서 아이템을 클릭하면 다이얼로드가 나타납니다.
이때 다이얼로그 타이틀과 db안의 한 데이터를 비교해서 같으면 리스트뷰에 보이게 하려고 하는데요
어떻게 해야 할까요??
현재는 어떤 아이템을 눌러도 리스트뷰 안에 나타나게 되네요
public void onItemClick(AdapterView<?> parent, View v, final int position, long id)
{
Log.i("Test","1");
cursor.moveToFirst();
Context mContext = getApplicationContext(); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.list_sch, (ViewGroup)findViewById(R.id.listlayout)); listSchedule = (ListView)layout.findViewById(R.id.listSchedule); listSchedule.setAdapter(scheduleAdapter);
scheduleAdapter = new CursorAdapter(mContext, cursor) {
@Override
public void bindView(View view, Context context, Cursor cursor) {
Log.i("Test","bindview");
final TextView scheduletext = (TextView)view.findViewById(R.id.scheduletext);
// if(mTvCalendarTitle.getText() + " " + mCalendarAdapter.tiseday(position) +"일" == cursor.getString(cursor.getColumnIndex("name"))) {
// }
scheduletext.setText(cursor.getString(cursor.getColumnIndex("name")));
Log.i("Test", cursor.getString(cursor.getColumnIndex("name")));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// TODO Auto-generated method stub
Log.i("Test","newview");
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.sche, parent, false);
return v;
}
};
//String str_date = mDayList.get(position).getDay(); final AlertDialog.Builder aDialog = new AlertDialog.Builder(this); aDialog.setTitle(mTvCalendarTitle.getText() + " " + mCalendarAdapter.tiseday(position) +"일" ); aDialog.setView(layout);
aDialog.setPositiveButton("이전날", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
aDialog.setTitle(mTvCalendarTitle.getText() + " " + mCalendarAdapter.tiseday(position-1) +"일");
aDialog.show();
}
});
aDialog.setNeutralButton("일정 추가", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
//scheduleAdapter();
it = new Intent(A_Team_Pro_Test1_Calendar.this, A_Team_Pro_Test1_Schedule.class);
it.putExtra("date", mTvCalendarTitle.getText() + " " + mCalendarAdapter.tiseday(position) +"일");
startActivity(it);
//finish();
}
});
aDialog.setNegativeButton("다음날", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
aDialog.setTitle(mTvCalendarTitle.getText() + " " + mCalendarAdapter.tiseday(position+1) +"일");
aDialog.show();
} });
aDialog.show(); }//캘린더 아이템을 클릭시 발생하는 이벤트에 대한 설정(onItemClickListener)



