我有一个按钮,点击它我会显示一个多选对话框。我用数据库中的值加载对话框。我想跟踪检查的对话框中的值。我怎么做??是否可以在最初加载对话框时检查某些服务。我的 ButtonOnClickHandler 代码如下所示:
class ButtonClickHandler implements View.OnClickListener {
public void onClick( View view ) {
int i=0;
List<Service> svc = EditBusinessdh.getServiceList();
Log.v(TAG, "Setting svc size:"+ svc.size() );
serName = new ArrayList<String>();
for(i=0;i<svc.size();i++)
{
serName.add(svc.get(i).toString());
Log.v(TAG, "service ="+svc.get(i));
}
showDialog(0);
}
}
@Override
protected Dialog onCreateDialog(int id)
{
String[] ser = serName.toString().substring(1,serName.toString().length()-1).split(",");
return new AlertDialog.Builder( this )
.setTitle( "Select Services" )
.setMultiChoiceItems(ser, selected, new DialogSelectionClickHandler())
.setPositiveButton( "Ok", new DialogButtonClickHandler() )
.create();
}
public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
{
public void onClick( DialogInterface dialog, int clicked, boolean checked )
{
String firstSelected= serName.set(clicked, ser.toString());
}
}
public class DialogButtonClickHandler implements DialogInterface.OnClickListener
{
public void onClick( DialogInterface dialog, int clicked )
{
switch( clicked )
{
case DialogInterface.BUTTON_POSITIVE:
closeContextMenu();
break;
case DialogInterface.BUTTON_NEGATIVE:
break;
}
}
}
@Override
public void closeContextMenu() {
super.closeContextMenu();
}
谢谢