1. package com.android.Dday;
  2. import java.util.*;
  3. //import com.ulsan.*;
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6. import android.widget.*;
  7. public class DdayActivity extends Activity {
  8. DatePicker mdate;
  9. int mYear, mMonth, mDay,dYear,dMonth,dDay;
  10. /** Called when the activity is first created. */
  11. @Override
  12. public void onCreate(Bundle savedInstanceState) {
  13. super.onCreate(savedInstanceState);
  14. setContentView(R.layout.widget);
  15. setContentView(R.layout.add);
  16. DatePicker mdate = (DatePicker) findViewById(R.id.datepicker); //Create DatePicker
  17. mYear = today.get(Calendar.YEAR); //today's year
  18. mMonth = today.get(Calendar.MONTH); //today's month
  19. mDay = today.get(Calendar.DAY_OF_MONTH); //today's day
  20. mdate.init(mYear, mMonth, mDay,
  21. new DatePicker.OnDateChangedListener() {
  22. public void onDateChanged(DatePicker view, int year, //monthOfYear===month(start at 0)
  23. int monthOfYear, int dayOfMonth) {
  24. dday.set(year,monthOfYear,dayOfMonth);
  25. long diff_ms = (dday.getTimeInMillis()-today.getTimeInMillis())/1000;
  26. long diff_day = diff_ms/(24*60*60);
  27. }
  28. });
  29. }
  30. }

 

 

 

위젯 부분 제외하고 datepicker부분 이벤트 처리를 하고있는데용...지금제가 맞게 짜고 있는건지 잘 모르겠어요 .. ㅠ_ㅠ 맞게 하고 있는건가요?

거의 안배우고 하는거라 책찾고 인터넷 찾아가면서 하는건데 완벽히 이해하지 못해서 그런지 아직 엄청 서투네요 ㅠ.ㅠ

맞는건지 확인 좀 부탁드립니당~ ㅠ.ㅠ.......

diff_ms 와 diff_day 는 밀리초단위의 차이랑 일수 차이를 계산한겁니당~

아 그리구 여기서............ 위젯으로 D-(날짜, 즉 diff_day) 를 출력하려면 어디에 어떻게 소스를 짜야하나요?ㅠㅠㅠ