0
저는 CalendarView에서 작동하는 아주 기본적인 pqctice 앱을 가지고 있습니다. 나는 현재와 다른 날짜가 호출 된 날짜를 표시하는 축배를 원합니다. 주요 활동이 잘 표시되고보기가 작동하지만 토스트가 표시되지 않습니다. 내가 뭘 놓치고 있니?토스트가 내 에뮬레이터에 표시되지 않는 이유는 무엇입니까?
내 MainActivity 코드 :
public class MainActivity extends AppCompatActivity implements OnDateChangeListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
base = (CalendarView) findViewById(R.id.calendarView);
date = base.getDate();
base.setOnDateChangeListener(new OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
if(base.getDate() != date) {
date = base.getDate();
Toast.makeText(view.getContext(), month + "/" + dayOfMonth + "/" + year, Toast.LENGTH_LONG).show();
}
}
});
}
는 XML :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.practice.andrea.whysoobsessedwithcalendars.MainActivity">
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.practice.andrea.whysoobsessedwithcalendars.MainActivity"
>
<CalendarView
android:layout_width="250dp"
android:layout_height="250dp"
android:id="@+id/calendarView"
android:layout_centerVertical="true"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView"/>
</FrameLayout>
</RelativeLayout>
가 다시 정말 기본적인 것들이어야한다. 왜 작동하지 않는지 모르겠습니다. 어떤 아이디어?
나는 이것을 시도 할 것이다 : Toast.makeText (MainActivity.this, month + "/"+ dayOfMonth + "/"+ year, Toast.LENGTH_LONG) .show(); – Lino