我想在弹开手指时检测弹出窗口中的按钮。
我想要弹出窗口,例如AOSP或a.i.type键盘。
这是我显示弹出窗口的代码。
@Override
public void onPress(int i) {
View custom = LayoutInflater.from(this).inflate(R.layout.popupkey, new FrameLayout(this));
final PopupWindow popup = new PopupWindow(this);
popup.setContentView(custom);
popup.setWidth(FrameLayout.LayoutParams.WRAP_CONTENT);
popup.setHeight(FrameLayout.LayoutParams.WRAP_CONTENT);
popup.showAtLocation(keyboardView, Gravity.NO_GRAVITY, 0, 0);
keyboardView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(popup != null && motionEvent.getAction() == MotionEvent.ACTION_UP) {
popup.dismiss();
}
return false;
}
});
}