且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何优化这个对话框code为Android?

更新时间:2023-02-03 19:17:57

要解决的背景颜色的问题,我刚才设置

To fix the background color problem i just set

builder.setInverseBackgroundForced(true);

所以我完全code是

so my complete code is

View view = View.inflate(this, R.layout.tos_dialog, null);

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setIcon(R.drawable.icon);
builder.setTitle("Bla bla title");
builder.setView(view);
builder.setInverseBackgroundForced(true);
builder.setPositiveButton("I agree", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
       }
   });
builder.setNegativeButton("I don't agree", new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int id) {
          Bingo.this.finish();
       }
    });
AlertDialog alert = builder.create();
alert.show();

和视图文本与自动链接充气XML

and the inflated xml for the view with text with autolinks

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/root" 
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="10px"
android:textColor="#000"
android:gravity="left"
android:textSize="14px"
android:background="#FFF"
android:autoLink="all"
android:textColorLink="#00F"
android:text="bla bla http://***.com is cool, bla bla."
/>