我想要如下所示的对话框。 。因此,我以AlertDialog以及使用自定义警报对话框的形式打开了活动。自定义AlertDialog的代码如下所示
LayoutInflater inflater = LayoutInflater.from(this);
View dialogLayout = inflater.inflate(R.layout.add_user_dialoge, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialogLayout);
AlertDialog customAlertDialog = builder.create();
WindowManager.LayoutParams wmlp = customAlertDialog.getWindow().getAttributes();
wmlp.gravity = Gravity.TOP | Gravity.START;
wmlp.y = 120;//y position
customAlertDialog.show();
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int displayWidth = displayMetrics.widthPixels;
int dialogWindowWidth = (int) (displayWidth *2);
wmlp.width = dialogWindowWidth;
customAlertDialog.getWindow().setAttributes(wmlp);
答案 0 :(得分:1)
可以通过两种方式完成操作,第一种在style.xml中,第二种在代码中:
<html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta charset="utf-8"> <?php ... $name = $_POST['cust_name']; $name = iconv('UTF-8', 'UTF-16LE', $name); $name = bin2hex($name); $sql = "INSERT INTO inv01 (cust) VALUES (CONVERT(nvarchar(MAX), 0x".$value."))"; ... ?> </head> <body></body> </html>
<style name="Theme_Dialog" parent="android:Theme.Holo.Dialog"> <item name="android:windowMinWidthMajor">90%</item> <item name="android:windowMinWidthMinor">90%</item> </style>
final Dialog contacts_dialog = new Dialog(ActivityGroup.this,
R.style.theme_sms_receive_dialog);
contacts_dialog.setContentView(R.layout.dialog_schedule_date_time);