Android Dialog 示例转载请注明出处:【菜鸟的成长史http://blog.csdn.net/zjbpku/article/details/7836587】
Android Dialog 示例
转载请注明出处:【菜鸟的成长史http://blog.csdn.net/zjbpku/article/details/7836587】
最近对Dialog的使用比较频繁,在这个过程中发现经常用到的对话框也就几种,个人将其总结为以下几种:
样式一:
代码:
代码:
代码:
代码:
xml:
命名为layout.xml,置于layout文件夹下
LayoutInflater inflater = getLayoutInflater();View layout = inflater.inflate(R.layout.layout, null);AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);builder.setTitle("自定义布局").setView(layout).setPositiveButton("确定", null).setNegativeButton("取消", null).show();如果要获取EditView中的数据可在xml中定义id,然后 获取edit = (EditText)findViewById(id),通过getText()方法获取
