下面的类是在Test.java文件中,我想从public class Test的函数中调用它。 现在我不知道如何访问该功能来显示alertdialog
。我的意思是如何从另一种方法访问下面的类的onCreateDialog(Bundle savedInstanceState)
?android中的自定义提醒框
下面的代码是从this source
class MyCustomDialog extends DialogFragment{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.notification_list_layout, null))
// Add action buttons
.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// sign in the user ...
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyCustomDialog.this.getDialog().cancel();
}
});
return builder.create();
}
}
复制我想是这样的
我卡在这里。只是不知道如何获得它 – magicgb
不知道你的问题,但http://stackoverflow.com/a/8311800/1777090可能有帮助 –
我不知道如何访问类的onCreateDialog(Bundle savedInstanceState)类MyCustomDialog,这样我可以弹出一个如上定义的警告框 – magicgb