很漂亮的自定义的AlertDialog的对话框
2017-08-11 17:54
106 查看
请尊重原创;过后会上传源码,或者联系我
看图效果
不多说,上代码
很简洁的代码
在sytle应用
可以随时修改各种的文字大小信息
三、归纳
可以看到整篇文章的核心就是
掌握了这个方法,对于修改 AlertDialog 就不在话下,当然此方法的用处在这里只能算的上是冰上一脚。
需要对 AlertDialog 的各个控件熟练运用就必须知道系统的alert_dialog.xml定义了那些 View,alert_dialog.xml的路径是
看图效果
不多说,上代码
public void init(){ final View textEntryView=factory.inflate(R.layout.dialog_layout,null); dlg=new AlertDialog.Builder(MainActivity.this).setView(textEntryView).create(); dlg=new AlertDialog.Builder(MainActivity.this,R.style.MyDialog).create(); dlg.setView(mLayout,0,0,0,0); dlg.show(); TextView tvvolam= (TextView)mLayout.findViewById(R.id.volem); tvvolam.setText("4510"); // EditText secondPwd = (EditText) mLayout.findViewById(R.id.etvolam); // final String inputPwd = secondPwd.getText().toString(); canel= (Button) mLayout.findViewById(R.id.dialog_button_cancel); ok= (Button) mLayout.findViewById(R.id.dialog_button_ok); canel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dlg.dismiss(); makeWindowLight(); } }); ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText secondPwd = (EditText) mLayout.findViewById(R.id.etvolam); final String inputPwd = secondPwd.getText().toString(); if("".equals(inputPwd)){ Toast.makeText(MainActivity.this,"不能为空",Toast.LENGTH_LONG).show(); }else{ Toast.makeText(MainActivity.this,"提交成功",Toast.LENGTH_LONG).show(); dlg.dismiss(); makeWindowLight(); } // dlg.dismiss(); //makeWindowLight(); } }); }
很简洁的代码
在sytle应用
<style name="MyDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@drawable/dialog</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> </style>
可以随时修改各种的文字大小信息
三、归纳
可以看到整篇文章的核心就是
public int getIdentifier(String name, String defType, String defPackage)
掌握了这个方法,对于修改 AlertDialog 就不在话下,当然此方法的用处在这里只能算的上是冰上一脚。
需要对 AlertDialog 的各个控件熟练运用就必须知道系统的alert_dialog.xml定义了那些 View,alert_dialog.xml的路径是
相关文章推荐
- 自定义 Android 对话框 (AlertDialog) 的样式
- Dialog对话框之自定义AlertDialog
- 自定义 Android 对话框 (AlertDialog) 的样式
- android自定义AlertDialog对话框中的EditText无法弹出输入法解决方案
- Android中的AlertDialog使用示例五(自定义对话框)
- Androidの自定义对话框AlertDialog(一)
- 自定义 Android 对话框 (AlertDialog) 的样式
- Android 自定义AlertDialog退出对话框
- 自定义 Android 对话框 (AlertDialog) 的样式
- 自定义 Android 对话框 (AlertDialog) 的样式(转载)
- android 自定义Alertdialog对话框用于耗时加载
- Android--自定义对话框--AlertDialog
- 自定义一个退出AlertDialog(对话框)
- 自定义对话框AlertDialog
- Android 自定义AlertDialog对话框样式
- 自定义的对话框弹窗 AlertDialog
- AlertDialog对话框-自定义View
- Android常用的AlertDialog对话框及自定义对话框
- 自定义 Android 对话框 (AlertDialog) 的样式
- android:常用的AlertDialog对话框及自定义对话框