0
我想在另一個活動中顯示日曆中的選定日期,所以請幫助我,現在在我的應用程序中顯示當前日期,但我不知道如何執行此操作。我在我的應用程序中使用簡單的彈出式日曆。下面是我的代碼。使用彈出日曆在另一個活動中顯示選定的日期
sharedpreferences = getSharedPreferences(MyPREFERENCES, MODE_PRIVATE);
Bundle b = getIntent().getExtras();
txt_date = (TextView) findViewById(R.id.Date_Value);
txt_week = (TextView) findViewById(R.id.Week_Value);
txt_baby = (TextView) findViewById(R.id.Baby_Value);
txt_mother = (TextView) findViewById(R.id.Mother_Value);
txt_tremester = (TextView) findViewById(R.id.Tremester_Value);
txt_baby.setText(b.getCharSequence("baby_name"));
txt_mother.setText(b.getCharSequence("mother_name"));
txt_tremester.setText(b.getCharSequence("tremester"));
img_week = (ImageView) findViewById(R.id.image_week);
img_slide = (ImageView) findViewById(R.id.image_slide);
img_BMI = (ImageView) findViewById(R.id.image_BMI);
img_setting = (ImageView) findViewById(R.id.image_setting);
String dob = sharedpreferences.getString("dob", null);
Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
txt_date.setText(new StringBuilder()
// Month is 0 based, just add 1
.append(year).append("-").append(month + 1).append("-").append(day));
String current_dob = txt_date.getText().toString();
StringTokenizer current_tokens = new StringTokenizer(current_dob, "-");
current_year = current_tokens.nextToken();
current_month = current_tokens.nextToken();
current_date = current_tokens.nextToken();
System.out.println("year==>" + Integer.parseInt(current_year));
System.out.println("month==>" + Integer.parseInt(current_month));
System.out.println("date==>" + Integer.parseInt(current_date));
StringTokenizer tokens = new StringTokenizer(dob, "-");
selected_year = tokens.nextToken();
selected_month = tokens.nextToken();
selected_date = tokens.nextToken();
System.out.println("year==>" + Integer.parseInt(selected_year));
System.out.println("month==>" + Integer.parseInt(selected_month));
System.out.println("date==>" + Integer.parseInt(selected_date));