0
告訴我我做錯了什麼。從https://www.youtube.com/watch?v=ZHLCfqN-60A複製代碼,我看到類似的東西。 這就是:在CalendarView類對象上找不到類
的Java
package com.example.witek.calendarexample;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CalendarView;
import android.widget.Toast;
public class CalendarExampleActivity extends AppCompatActivity {
CalendarView calendarView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calendar_example);
}
calendarView = (CalendarView) findViewById(R.id.cal);
calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView calendarView, int i, int i1, int i2) {
Toast.makeText(getApplicationContext(), "Selected Date:\n" + "Day = " + i2 + "\n" + "Month = " + i1 + "\n" + "Year = " + i, Toast.LENGTH_LONG).show();
}
});
}
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.witek.calendarexample.CalendarExampleActivity">
<CalendarView android:id="@+id/cal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
任何建議? 我將不勝感激。
Thx很多! 對不起,我忘了添加occuring錯誤..:/ – Azbesciak