首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

alertdialog显示checkboxes的有关问题

2012-08-28 
alertdialog显示checkboxes的问题想在alertdialog上显示一个多个选项的对话框如下public void showSetting

alertdialog显示checkboxes的问题

想在alertdialog上显示一个多个选项的对话框如下

public void showSettingsBox(){?
? final CharSequence[] items = {"Item1", "Item2", "Item3"};?
? final boolean checked[] = new boolean[]{false,false,false};?
?
? AlertDialog.Builder builder = new AlertDialog.Builder(fLabyrinthGame); ?
? builder.setMessage(fMessage)?
? ?.setCancelable(false)?
? ?.setMultiChoiceItems(items, checked, new OnMultiChoiceClickListener() {?
?
? ? @Override?
? ? public void onClick(DialogInterface dialog, int which, boolean isChecked) {?
? ? ?CharSequence text = "Item number " + which;?
? ? ?int duration = Toast.LENGTH_SHORT;?
?
? ? ?Toast toast = Toast.makeText(fLabyrinthGame, text, duration);?
? ? ?toast.show();?
?
? ? }?
? ?})?
? ?.setPositiveButton("Apply", new DialogInterface.OnClickListener() {?
? ? public void onClick(DialogInterface dialog, int id) {?
? ? ?dialog.cancel();?
? ? }?
? ?});?
? builder.setTitle(fTitle); ?
? builder.setIcon(R.drawable.icon_exclamation); ?
?
? AlertDialog alert = builder.create(); ?
?
? alert.show(); ? ?
?}?
结果出现一个空白除了最后一个按钮

?

要想实现功能需要去掉setMessage(fMessage),这是因为setMultiChoiceItems or setItems 是互相冲突的貌似

1 楼 njlz8888 2011-08-02   我也遇到这个问题了,请问您是怎么解决的??

热点排行