就是用AlertDialog来实现的,不过你要自定义一下他的view就可以了,很简单的// 自定义AlertDialog
LayoutInflater factory = LayoutInflater.from(this);
// 定义view,R.layout.notification是自己定义的layout文件
final View textEntryView = factory.inflate(R.layout.notification, null);
//TextView 是在R.layout.notification里面定义的,你可以换成你的EditView
TextView tv1 = (TextView) textEntryView.findViewById(R.id.contactText);
tv1.setText(getResources().getString(R.string.sms_recipient) + numberRe);
TextView tv2 = (TextView) textEntryView.findViewById(R.id.contentText);
tv2.setText(getResources().getString(R.string.sms_content) + cotentRe);
TextView tv3 = (TextView) textEntryView.findViewById(R.id.notifyText);
//创建对话框,调用setView设置textEntryView为对话框的View就可以实现你需要的功能了
return new AlertDialog.Builder(SmsTimerAlarmReceiver.this).setIcon(R.drawable.alert_dialog_icon).setTitle(
R.string.alarm_dialog_title).setView(textEntryView)
.setPositiveButton(R.string.confirm,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//按键事件
}
})
.setNegativeButton(R.string.cancel_sending, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//按键事件
}
}).create();
LayoutInflater factory = LayoutInflater.from(this);
// 定义view,R.layout.notification是自己定义的layout文件
final View textEntryView = factory.inflate(R.layout.notification, null);
//TextView 是在R.layout.notification里面定义的,你可以换成你的EditView
TextView tv1 = (TextView) textEntryView.findViewById(R.id.contactText);
tv1.setText(getResources().getString(R.string.sms_recipient) + numberRe);
TextView tv2 = (TextView) textEntryView.findViewById(R.id.contentText);
tv2.setText(getResources().getString(R.string.sms_content) + cotentRe);
TextView tv3 = (TextView) textEntryView.findViewById(R.id.notifyText);
//创建对话框,调用setView设置textEntryView为对话框的View就可以实现你需要的功能了
return new AlertDialog.Builder(SmsTimerAlarmReceiver.this).setIcon(R.drawable.alert_dialog_icon).setTitle(
R.string.alarm_dialog_title).setView(textEntryView)
.setPositiveButton(R.string.confirm,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//按键事件
}
})
.setNegativeButton(R.string.cancel_sending, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//按键事件
}
}).create();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货