如何与微调进行警告对话

我知道如何进行一个警告对话框,但是我需要使用一个微调框来创build一个对话框,以便在popup对话框时可以select发生什么。 有没有人有一个微调警告对话的代码或知道任何好的教程?

提前致谢

Solutions Collecting From Web of "如何与微调进行警告对话"

LayoutInflater li = LayoutInflater.from(context); View promptsView = li.inflate(R.layout.my_dialog_layout, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setView(promptsView); // set dialog message alertDialogBuilder.setTitle("My Dialog.."); alertDialogBuilder.setIcon(R.drawable.ic_launcher); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); final Spinner mSpinner= (Spinner) promptsView .findViewById(R.id.mySpinner); final Button mButton = (Button) promptsView .findViewById(R.id.myButton); // reference UI elements from my_dialog_layout in similar fashion mSpinner.setOnItemSelectedListener(new OnSpinnerItemClicked()); // show it alertDialog.show(); alertDialog.setCanceledOnTouchOutside(false); 

哪里

my_dialog_layout是包含Spinner mySpinner的popup式布局

编辑:

 public class OnSpinnerItemClicked implements OnItemSelectedListener { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Toast.makeText(parent.getContext(), "Clicked : " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); } @Override public void onNothingSelected(AdapterView parent) { // Do nothing. } }