Witam, na początku przepraszam jeżeli takie temat już był, lub źle opisałem problem, ale dopiero zaczynam przygodę z programowaniem na androida.
A więc pisze aplikacje która ma wyświetlać kalendarz a na dole chciałbym żeby pojawiały sie przyciski "Cancel" i "Ok" jak na razie wyświetla mi sie kalendarz, ale bez tych przycisków :/
jak je dodać? oraz jak później podpiąć pod nie jakaś akcję??(wyświetlenie napisu po wciśnięciu któregoś z klawisza)
Mój kod:
package com.example.szupek.datepickerszupek;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CalendarView;
import android.widget.TextView;
import android.view.Menu;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
CalendarView simpleCalendarView;
TextView dateDisplay;
Calendar c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dateDisplay = (TextView) findViewById(R.id.textView_display);
dateDisplay.setText("Date: ");
simpleCalendarView = (CalendarView) findViewById(R.id.simpleCalendarView); // get the reference of CalendarView
simpleCalendarView.setFocusedMonthDateColor(Color.RED); // set the red color for the dates of focused month
simpleCalendarView.setUnfocusedMonthDateColor(Color.BLUE); // set the yellow color for the dates of an unfocused month
simpleCalendarView.setSelectedWeekBackgroundColor(Color.RED); // red color for the selected week's background
simpleCalendarView.setWeekSeparatorLineColor(Color.GREEN); // green color for the week separator line+
c=Calendar.getInstance();
int year_c = c.get(Calendar.YEAR);
int mont_c = c.get(Calendar.MONTH);
int day_c = c.get(Calendar.DAY_OF_MONTH);
dateDisplay.setText("Date: "+ year_c+"/"+(mont_c+1)+"/"+day_c);
// perform setOnDateChangeListener event on CalendarView
simpleCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
dateDisplay.setText("Date: " + year + " / " + month + " / " + dayOfMonth);
}
});
}
}
W załączniku dodałem zdjęcie jak chciałbym zeby to wyglądało - Ok i cancel na dole kalendarza.
Pozdrawiam i czekam na odpowiedź
Grzesiek