我继承了一个Dialog
public class Dialog_query extends Dialog implements OnClickListener { }
通过xml定义了一个界面,
现在想通过点击日期1来选择日期,代码如下
暂记为:“代码button”
Button btn=(Button)findViewById(R.id.BtnDate); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new DatePickerDialog(Dialog_query.this, d2, dateAndTime.get(Calendar.YEAR), dateAndTime.get(Calendar.MONTH), dateAndTime.get(Calendar.DAY_OF_MONTH) ).show(); } });
现在遇到的问题是,提示“The constructor DatePickerDialog(Dialog_query, DatePickerDialog.OnDateSetListener, int, int, int) is undefined”
后来发觉在这里添加Toast.makeText(LoginSuccess.this, "关于 敏捷软件 1.0", Toast.LENGTH_LONG).show();
也会提示“The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (Dialog_query, String, int)”
但是“代码button”在Activity的情况下是正确的。
为什么在继承的情况下会提示这样的错误呢?
是不是因为继承,所以执行DatePickerDialog或是makeText,要添加其他的关键字呢?
盼回复,谢谢。