Reputation: 21
i want to detect button in my popup when i removed my finger on it.
i want popup like AOSP or a.i.type keyboard.
this is my code for show popup .
@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;
}
});
}
Upvotes: 1
Views: 65