效果图:
点击
?主要代码:
Activity
mButton1 = (Button)findViewById(R.id.btn1); mButton1.setText("测试弹出选择框"); mTextView1 = (TextView)findViewById(R.id.tv); mButton1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(Activity18.this) // build AlertDialog .setTitle("选择语言") // title .setItems(R.array.items, new DialogInterface.OnClickListener() { //content @Override public void onClick(DialogInterface dialog, int which) { final String[] aryShop = getResources().getStringArray(R.array.items); //array new AlertDialog.Builder(Activity18.this) .setMessage("你选择的是:" + aryShop[which]) .setNeutralButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); } }) .setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); //关闭alertDialog } }) .show(); } });?