在扩展的 EditText 中长按显示弹出窗口 class

Display a popup on long click in extended EditText class

我尝试编写 EditText 的派生 class 用于日期

public class myEditDate extends EditText {
    protected Context mContext; // Current activity
    ...

它工作正常,我添加了一些 utils 日期函数,但我尝试显示带有 CalendarView 小部件的弹出窗口 windows。 在 LongClickListener 事件中我调用

private void ShowCalendar()
{
    LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mv_CALENDAR = layoutInflater.inflate(R.layout.editdate_calendar, null);

    final PopupWindow popupWindow = new PopupWindow(mv_CALENDAR, 400, 400);
}

我有一个错误:

   editdate_calendar cannot be resolved or is not a field

我认为这是因为我进入了一个领域 class 而不是 activity class 我该如何解决

editdate_calendar.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/layout"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
 <CalendarView
    android:id="@+id/calendarView"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    android:clickable="true"
    android:showWeekNumber="false" />
 </LinearLayout>

我找到了:

替换 导入 android.R; 经过 导入 myPackage.R;

抱歉,我使用 CTRL + Shift + o 添加缺少的导入但没有看到它