private void showSingleChoiceDialog(){ final String[] items = { "01","02","03","04"}; final AlertDialog.Builder singleChoiceDialog = new AlertDialog.Builder(MainActivity.this); singleChoiceDialog.setTitle("我是一个单选Dialog"); // 第二个参数是默认选项,此处设置为0 singleChoiceDialog.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mFishEyeMode = which; MyLog.LOGI(TAG, "setSingleChoiceItems: mFishEyeMode="+mFishEyeMode); } }); singleChoiceDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mFishEyeMode == -1) { mFishEyeMode = 0; } new Thread(){ @Override public void run(){ InitFishEye(); } }.start(); } }); singleChoiceDialog.show(); }
Android的Dialog选择框的实现
最新推荐文章于 2024-08-10 21:22:45 发布