I'm trying to add a Date Picker to my code, but an error is being shown over "pickerListener" inside the "fromDate_textView.setOnClickListener" saying:
pickerListener cannot be resolved to a variable
Can anyone please help me solve the issue?
fromDate_textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
showDialog(DatePickerDialog(Sell_Product_Activity.this,
pickerListener, year, month, day));
}
});
DatePickerDialog.OnDateSetListener pickerListener = new DatePickerDialog.OnDateSetListener() {
// when dialog box is closed, below method will be called.
@Override
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
// Show selected date
fromDate_textView.setText(new StringBuilder().append(month + 1)
.append("-").append(day).append("-").append(year)
.append(" "));
}
};
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…