如何解决在警告对话框中显示条款和条件 - android
我正在编写自己的 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()) 中。好长啊,有没有更好的办法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。