0

我希望在用户打开 EditText 进行编辑时打开一个弹出窗口。这是我的基本代码。

toDate.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            // TODO Auto-generated method stub

            initiatePopupWindow();
            return false;
        }
    });
}


protected void initiatePopupWindow() {
    // TODO Auto-generated method stub

    try {
        popDate = (LayoutInflater) TripData.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = popDate.inflate(R.layout.popdate, (ViewGroup) findViewById(R.id.popup));

        datePw = new PopupWindow(layout, 300, 370, true);
        datePw.showAtLocation(layout, Gravity.CENTER, 0, 0);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

toDate 是 EditText。我知道问题是我没有指定任何操作。我的问题是,我不知道如何指定操作。

4

1 回答 1

0

What do you mean with "when a user opens an EditText for editing"? If you mean that the action should perform when the EditText becomes "active", then you might probably want:

setOnFocusChangeListener() reference page

Hope this helps

于 2013-05-27T18:53:06.770 回答