在EditText添加TextWatcher的事件,afterTextChanged方法里添加数据接口的调用,然后弹出popupWindow,具体如下:
public void showCarNumberWindow(View anchor) {
if (carListPopup == null) {
carListPopup = new PopupWindow(this);
carListPopup.setWidth(anchor.getWidth()+20);
carListPopup.setHeight(ScreenUtils.dp2px(this, 220));
carListPopup.setBackgroundDrawable(new ColorDrawable(0x00000000));
carListPopup.setOutsideTouchable(true);
carListPopup.setFocusable(false);
View view = LayoutInflater.from(this).inflate(R.layout.car_numer_list, null);
carListPopup.setContentView(view);
} else {
carItemAdatper.setNewData(mReceiveGoodsViewModel.mCarList.getValue());
}
if (!carListPopup.isShowing()) {
carListPopup.showAsDropDown(anchor);
}
}
setFocusable(false),必须要设置为false,不然会影响组件的键盘输入和android的返回键。
网友评论