monthView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SQLiteDatabase db = m_Helper.getReadableDatabase();
String _id = MainActivity.p_id;
String message = "";
String friend = "";
String time = "";
String _date;
month= monthViewAdapter.getCurMonth();
MonthItem curItem = (MonthItem) monthViewAdapter.getItem(position);
day = curItem.getDay();
Day = day;
Toast.makeText(getApplicationContext(),month+1+"월 "+ day + "일이 선택되었습니다.", 1000).show();
monthViewAdapter.setSelectedPosition(position);
monthViewAdapter.notifyDataSetChanged();
// set schedule to the TextView
curPosition = position;
outScheduleList = monthViewAdapter.getSchedule(position);
if (outScheduleList != null) {
outScheduleList = new ArrayList<ScheduleListItem>();
scheduleAdapter.scheduleList = outScheduleList;
scheduleAdapter.notifyDataSetChanged();
}
if(ScheduleInputActivity.count>0){
Cursor cursor = db.query(true, "schedule_info",new String[]{"id","day","todo","friend","date"},
null,null,null,null,null,null);
while(cursor.moveToNext()){
String Id=cursor.getString(cursor.getColumnIndex("id"));
String curdate=cursor.getString(cursor.getColumnIndex("date"));
message = cursor.getString(cursor.getColumnIndex("todo"));
friend = cursor.getString(cursor.getColumnIndex("friend"));
time = cursor.getString(cursor.getColumnIndex("day"));
if(Id.equals(_id)){
String day2=Integer.toString(Day);
if(curdate.equals(day2)){
if(message!=null){
aItem = new ScheduleListItem(time, message, friend);
scheduleAdapter.removeItem(aItem);
outScheduleList.add(aItem);
scheduleAdapter.scheduleList = outScheduleList;
scheduleAdapter.notifyDataSetChanged();
//cursor.close();
}
}
}
}
}
}
});
코드를 이렇게 작성후 어플을 실행하면 처음 로그인했을때에는 정상적으로 작동하지만 로그아웃 후 다시 재 로그인을 했을 경우에는 어플이 자동으로 꺼지게 됩니다. 그리고 아래와 같은 에러가 발생하는데 어떤부분을 손봐야 할지 잘 모르겠습니다.
06-22 07:29:21.939: E/AndroidRuntime(1628): FATAL EXCEPTION: main
06-22 07:29:21.939: E/AndroidRuntime(1628): java.lang.NullPointerException
06-22 07:29:21.939: E/AndroidRuntime(1628): at exam.sss.CalendarMonthViewActivity$1.onItemClick(CalendarMonthViewActivity.java:130)
06-22 07:29:21.939: E/AndroidRuntime(1628): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
06-22 07:29:21.939: E/AndroidRuntime(1628): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
06-22 07:29:21.939: E/AndroidRuntime(1628): at android.os.Handler.handleCallback(Handler.java:587)
06-22 07:29:21.939: E/AndroidRuntime(1628): at android.os.Handler.dispatchMessage(Handler.java:92)
06-22 07:29:21.939: E/AndroidRuntime(1628): at android.os.Looper.loop(Looper.java:123)
06-22 07:29:21.939: E/AndroidRuntime(1628): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-22 07:29:21.939: E/AndroidRuntime(1628): at java.lang.reflect.Method.invokeNative(Native Method)
06-22 07:29:21.939: E/AndroidRuntime(1628): at java.lang.reflect.Method.invoke(Method.java:521)
06-22 07:29:21.939: E/AndroidRuntime(1628): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-22 07:29:21.939: E/AndroidRuntime(1628): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-22 07:29:21.939: E/AndroidRuntime(1628): at dalvik.system.NativeStart.main(Native Method)