android edittext 浮动标签,Android Edittext Popupwindow 筛选

今天遇到一个需求,就是EdittText + PopupWindow 用户在EdittTex输入后,PopupWindow筛选展示出来,先看效果图:

4004214baa06

GIF.gif

如上,我贴重要的代码,然后Demo在末尾

/**

* 初始化PopupWindow 关键代码

*/

private void initPopuWindow(){

if (!init){

View view1 = mActivity.getLayoutInflater().inflate(R.layout.popup_options, null);

listView = (ListView) view1.findViewById(R.id.list);

carAdapter = new ConfigurationFilterPopWindAdapter(mActivity, carStringList);

listView.setAdapter(carAdapter);

carShipNoPopWindow = new PopupWindow(view1, width, ViewGroup.LayoutParams.WRAP_CONTENT, true);

carShipNoPopWindow.setBackgroundDrawable(new ColorDrawable(0xb0000000));//背景色,半透明

carShipNoPopWindow.setFocusable(false);

carShipNoPopWindow.setOutsideTouchable(false);

carShipNoPopWindow.setAnimationStyle(R.style.animation_push_from_bottom);

carShipNoPopWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);

carShipNoPopWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

init = true;

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override

public void onItemClick(AdapterView> parent, View view, int position, long id) {

Toast.makeText(mActivity, carStringList.get(position), Toast.LENGTH_SHORT).show();

carShipNoPopWindow.dismiss();

}

});

}

}

异步筛选信息

/**

*作者:GaoXiaoXiong

*创建时间:2017/7/10

*注释描述:车牌号Runnable,异步刷新界面

*

* 关键代码

*/

Runnable carChangeRunnable = new Runnable() {

@Override

public void run() {

String data = etCarShipNo.getText().toString();

if (etCarShipNo.getText().length()==0)

return;

if (carShipNoPopWindow!=null&&!carShipNoPopWindow.isShowing()){

carShipNoPopWindow.showAsDropDown(etCarShipNo,0,-3);

}

if (carShipNoPopWindow==null){

width = etCarShipNo.getWidth();

initPopuWindow();

carShipNoPopWindow.showAsDropDown(etCarShipNo,0,-3);

}

carStringList.clear();//先要清空,不然会叠加

getNewData("10", data,newCarString);//获取更新数据

carAdapter.notifyDataSetChanged();//更新

}

};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值