如何实现一个自定义AlertDialog?

创建一个AlertDialog

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;

.....

        int choiceItem = -1;

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        String[] choices = getResources().getStringArray(R.array.gif_auto_play_type);
        int type = PreferencesUtil.getInstance(this).getAutoPlaySetting();
        builder.setSingleChoiceItems(choices, type, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                choiceItem = which;
            }
        });

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                PreferencesUtil.getInstance(SettingActivity.this).saveAutoPlaySetting(choiceItem);
            }
        });
        builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        
        builder.show();
        

创建Style



    
    
    
  

创建数据

    
        Mobile data and WiFi
        WiFi only
        Never
    

你可能感兴趣的:(如何实现一个自定义AlertDialog?)