How to highlight a date in the Calendarview widget?

Asked

Viewed 263 times

0

XML of the project

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.demetrius.calendario.MainActivity">

<CalendarView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/calendario">
</CalendarView>
<Button
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_gravity="center"
    android:onClick="mostrar_data"
    android:text="Mostrar data"/>
</LinearLayout>

java class of the project

public class MainActivity extends AppCompatActivity {

    CalendarView calendario;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setTitle(null);

        calendario = (CalendarView) findViewById(R.id.calendario);
        calendario.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            @Override
            public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
                String date = dayOfMonth + "/" + (month+1) + "/" + year;
                Log.d("teste",date);
            }
        });

    }
}
  • Explain it better there

  • in this widget the current date comes marked with a ball, I want to know how to mark other dates with this ball, preferably with a different color...

  • In case you want the current day marked with this pink ball , and mark other days with other colors?

  • yeah, that’s right

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.