本文介绍了对话框,在android系统自己的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个屏幕,在这里我有一些按钮。我想知道我可以做这样的事情:当我点击按钮的应用程序显示我与我的界面,我可以有两种editboxes,并在此对话框中作家的文字,我想有一个按钮,对话框。这是可以做到的对话与我自己的界面?
I have a screen where I have some buttons. I would like to know how can I do something like that: when I click on button app show me dialog with my interface where I can writer text in two editboxes and in this dialog I would like to have one button. This is possible to do dialog with my own interface?
推荐答案
是的,你可以actualy膨胀布局和生产它在警告对话框
yes you can actualy inflate a layout and produce it in an alert dialog
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(R.string.alert_dialog_text_entry)
.setView(textEntryView)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
})
.create();
这是从API样品中提供的示例code
this is from the sample code provided in the api samples
这篇关于对话框,在android系统自己的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!