博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
模仿淘宝搜索,弹出搜索浮层。
阅读量:7243 次
发布时间:2019-06-29

本文共 1592 字,大约阅读时间需要 5 分钟。

hot3.png

public class AllOrderSearchDialog extends Dialog {

        private Context context;
        private RelativeLayout allOrderSearchLeft;
        private EditText allOderSearchMiddle;
        private TextView allOderSeacrchRight;
        private String Title;
        public AllOrderSearchDialog(Context context, Handler myHandler, String title) {
                /* 设计Dialog样式 */
                super(context, R.style.MyDialog);
                this.myHandler = myHandler;
                this.context = context;
                this.title = title;
                setContentView(R.layout.all_order_dialog_view);
                /* 点击灰色区域让他取消浮层 */
                setCanceledOnTouchOutside(true);
                /* 关闭对话框取消 */
                setOnDismissListener(new OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                                // 更新AllOrdersActivity布局
                                new LooperThread().start();
                        }
                });
                // 设置布局显示位置、宽度、透明度、是否浮层
                LayoutParams layoutParams = getWindow().getAttributes();
                layoutParams.gravity = Gravity.TOP;
                layoutParams.width = YiWangApp.getInstance().getWindowWidth();
                layoutParams.alpha = 1.0f;
                getWindow().setAttributes(layoutParams);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                initSearchDialog();
        }
        private void initSearchDialog() {
                allOderSearchMiddle = (EditText) findViewById(R.id.all_oder_search_middle);
                allOderSearchMiddle.setText(title);
                allOderSearchMiddle.setSelection(allOderSearchMiddle.getText().length());
                allOderSeacrchRight = (TextView) findViewById(R.id.all_oder_search_right);
                getWindow().setSoftInputMode(
                                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
                                | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
                allOderSeacrchRight.setOnClickListener(new SearchViewOnClickListener());
        }
}

转载于:https://my.oschina.net/u/1035715/blog/282571

你可能感兴趣的文章
使用原理视角看 Git
查看>>
jooq-codegen-maven 的配置和使用
查看>>
如何处理Tomcat日志catalina.out日志文件过大的问题
查看>>
数据质量监控工具-Apache Griffin
查看>>
支付宝担保交易接口
查看>>
Intellij Idea中运行tomcat 后报内存溢出
查看>>
打开core文件功能
查看>>
nginx重新安装模块
查看>>
13个能快速开发android的经典项目
查看>>
HTML5给Button加链接
查看>>
git操作及fatal: Authentication failed for错误解决
查看>>
cpptest学习之LayerTest
查看>>
android GOOGLE MAP应用
查看>>
我们的开源项目-2013年度开源社区线下聚会《JEECG微云快速开发平台-SAAS企业应用在线开发与微信移动应用》PPT分享...
查看>>
Java 8 新特性(1) - Lambda表达式
查看>>
curl vs Wget
查看>>
安全应急响应
查看>>
maven_常用命令大全
查看>>
Android四大组件BroadcastReceiver
查看>>
apache ab
查看>>