I'm writing my own forum
app. I've a MaterialTextView
, I want to display an Alert
showing terms and conditions with OK
button. Here is the code:
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/desc"
android:text="@string/welcome_users"
android:fontFamily="@font/roboto_bold"
android:textSize="20sp"/>
Java code:
MaterialTextView desc;
@Override
protected void onCreate(Bundle savedInstanceState) {
desc = findViewById(R.id.desc);
desc.setOnClickListener(v -> showAlert());
}
private void showAlert() {
// setup the alert builder
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Terms and Conditions");
builder.setMessage("This is my message.");
// add a button
builder.setPositiveButton("OK", null);
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
}
I've a sample Terms and Conditions like this: https://www.wikihow.com/Sample/Terms-and-Conditions-for-Forum.
I want to insert that into body (setMessage()) of that alert dialog. It is long, is there any better way to acheive it?