我有 2 个活动。一是AlertDialogActivity& 二是MainActivity。我AlertDialogActivity在MainActivity.
像这样public class MainActivity extends AlertDialogActivity
现在如何覆盖AlertDialogActivity我的方法MainActivity?
警报对话活动:
package com.jimmytrivedi.alertdialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class AlertDialogActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alert_dialog);
showAlertDialog(AlertDialogActivity.this);
}
private void showAlertDialog(final Context context) {
// 1. Instantiate an <code><a href="/reference/android/app/AlertDialog.Builder.html">AlertDialog.Builder</a></code> with its constructor
AlertDialog.Builder builder = new AlertDialog.Builder(AlertDialogActivity.this);
// 2. Chain together various setter methods to set the dialog characteristics
builder.setMessage("How are you?")
.setTitle("Hello");
// 3. Get the <code><a href="/reference/android/app/AlertDialog.html">AlertDialog</a></code> from <code><a href="/reference/android/app/AlertDialog.Builder.html#create()">create()</a></code>
AlertDialog dialog = builder.create();
dialog.show();
}
}
莫回无
慕工程0101907
largeQ
相关分类