下面的类在文件 Test.java 中,我想从公共类 Test 的函数中调用它。现在我不知道如何访问该功能以显示alertdialog
. 我的意思是如何onCreateDialog(Bundle savedInstanceState)
从另一种方法访问下面的类?
下面的代码是从这个源复制的
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();
}
}
我想要这样的东西