我在写我自己的 forum
应用程序。我有一个 MaterialTextView
,我想显示 Alert
显示条款和条件 OK
按钮。代码如下:
<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();
}
我有这样的条款和条件示例:https://www.wikihow.com/sample/terms-and-conditions-for-forum.
我想将其插入警报对话框的主体(setmessage())。它很长,有没有更好的办法?
暂无答案!
目前还没有任何答案,快来回答吧!