import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.DatePicker;
import android.widget.TextView;
import java.util.Calendar;
public class DateDisplayPicker extends TextView implements DatePickerDialog.OnDateSetListener{
private Context _context;
public DateDisplayPicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
_context = context;
}
public DateDisplayPicker(Context context, AttributeSet attrs) {
super(context, attrs);
_context = context;
setAttributes();
}
public DateDisplayPicker(Context context) {
super(context);
_context = context;
setAttributes();
}
private void setAttributes() {
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showDateDialog();
}
});
}
private void showDateDialog() {
final Calendar c = Calendar.getInstance();
// DatePickerDialog dp = new DatePickerDialog(_context, this, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
DatePickerDialog dp = new DatePickerDialog(_context, AlertDialog.THEME_HOLO_DARK, this, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
dp.show();
}
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
setText(String.format("%s/%s/%s",year, (monthOfYear+1), dayOfMonth));
}
}
이렇게 만든 클래스를 xml에서 바로 사용할려고하는데 ..
선택된 값을 가져올 방법이 있나요?? 안되면 어떻게 해야되나요 ??