【发布时间】:2013-12-16 00:07:05
【问题描述】:
一直在尝试创建客户对话框,我从 android 网站复制了源代码。我已经完成了一些事情,现在我真的被困住了。我不知道代码中的LoginFragment是什么:
...
public class start extends Activity{
Button buttonx;
final Context context = this;
LayoutInflater mInflater;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
// Get the layout inflater
//LayoutInflater inflater = getActivity().getLayoutInflater();
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(mInflater.inflate(R.layout.login, null))
// Add action buttons
.setPositiveButton(R.string.signin, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// sign in the user ...
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
LoginDialogFragment.this.getDialog().cancel();
}
});
return builder.create();
}
当我//将行注释掉时,它说@Override 是不必要的,这不能解决任何问题。 对不起菜鸟问题
【问题讨论】:
-
LoginDialogFragment 必须是示例中使用的类名。你可以用你的活动名称来改变它。
标签: android android-fragments customdialog