添加一个数组
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("请选择以下城市");
builder.setMultiChoiceItems(R.array.city, new boolean[] { false, false, false },
new OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
// TODO Auto-generated method stub
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
});
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Android_multiDialog_test</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string-array name="city">
<item>北京</item>
<item>上海</item>
<item>广州</item>
</string-array>
</resources>