先上图
AlertDialog有个问题是动态添加组件时,组件会很靠边框,这样很不好看,下面这个方案是解决这个问题
LayoutInflater mInflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = mInflater.inflate(R.layout.recordlayout, null);
LinearLayout layout = (LinearLayout) view
.findViewById(R.id.id_recordlayout);
for (int i = 0; i < fieldName.length; i++) {
String name = fieldName[i];
if ("_id".equals(name))
continue;
TextView tv = new TextView(getContext());
tv.setText(fieldName[i]);
EditText edit = new EditText(getContext());
layout.addView(tv);
layout.addView(edit);
}
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
dialog.setTitle(R.string.add_a_record);
dialog.setView(view);
dialog.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
dialog.setNegativeButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
dialog.show();
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/id_recordlayout"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:padding="10dip"></LinearLayout>
</ScrollView>
- 大小: 15.8 KB
分享到:
相关推荐
android AlertDialog对话框的类型集合 ,比较全面的讲述了 AlertDialog 的 种类 , Demo 的综合性比较强 , Demo 可直接运行
Android alertDialog对话框.zip源码资源下载Android alertDialog对话框.zip源码资源下载
android AlertDialog使用例程 一个在安卓平台上开发使用AlertDialog的例子 很实用很全哦
* 各种功能实现弹窗(自定义弹窗位置,添加动画效果) * 1.设置AlertDialog弹窗并且2秒后自动关闭(自定义关闭AlertDialog) * 2.设置popuwindow弹窗并且2秒后自动关闭 * 3.弹出后自带震动提示
Android AlertDialog对话框 自定义实现遮罩层
android AlertDialog 单选 多选 输入框 疯狂android讲义
025_android UI组件之 AlertDialog 的各种实现,很细致的视频教程,这个可以学哦。。
026_android UI组件之 AlertDialog的自定义布局,很细致的视频教程,这个可以学哦。。
Android之AlertDialog源码
【Android】对话框 AlertDialog
Android alertDialog对话框.rar
Android alertDialog对话框.zip
Android之修改AlertDialog对话框及使用系统Holo风格
android 使用alertdialog创建自定义对话框
Android入门第九篇之AlertDialog.docx
安卓Android源码——alertDialog.rar
android自定义AlertDialog,例如支付页面,先弹出自定义AlertDialog询问是否愿意支付,确定则弹出另外一个自定义AlertDialog,选择支付方式,android自定义AlertDialog,android自定义AlertDialog,android自定义...
Android 模仿IOS7风格的底部对话框,我个人比较喜欢ios7的一些弹窗风格,这里模仿一下ios7的对话框,QQ安卓版也是做的和ios7一样的,弹出底部菜单列表和AlertDialog,本项目编码GBK默认编译版本4.2.2javaapk提供测试...