В настоящее время я пытаюсь получить дату (в частности, месяц и год) и отобразить ее с помощью TextView, но моя программа принудительно закрывается.
Здесь я "получаю" месяц и год.
Calendar cCalendar = Calendar.getInstance();
int currentYear = cCalendar.get(Calendar.YEAR);
int currentMonth = cCalendar.get(Calendar.MONTH);
Здесь я устанавливаю текст TextView.
public void setDateLabel(View v)
{
TextView month = (TextView)findViewById(R.id.monthLabel);
TextView year = (TextView)findViewById(R.id.yearLabel);
year.setText(currentYear);
month.setText(currentMonth);
}
Вот XML с TextView и кнопкой.
<TextView android:textAppearance="?android:attr/textAppearanceMedium" android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/monthLabel"></TextView>
<TextView android:textAppearance="?android:attr/textAppearanceMedium" android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/yearLabel"></TextView>
<Button android:text="Button" android:onClick="setDateLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/setDate"></Button>
Я пытаюсь запустить его вОтладка для получения LogCat, но отладчик просто останавливается и ожидает его «присоединения» к порту 8634.