I'm trying to create an AlertDialog (which should appear when the Textvie exercise is clicked), which includes a spinner as title. It should change the content of the dialog list, when a diffrent item is selected in the spinner.
exercise = (TextView)findViewById(R.id.add_exerc);
exercise.setText("TEST");
initExerOCL();  //init the OnItem
private void initExerOCL(){
    exercise.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //diaTitle is used for the String[] from which to create the dialogList
            AlertDialog a = showListCheckPickerDialog(diaTitle);
            a.show();
        }
    });
}
public AlertDialog showListCheckPickerDialog(int i){
    mSelectedItems = new ArrayList();  //saves selected items
    LayoutInflater inflater = getLayoutInflater();
    View v = inflater.inflate(R.layout.add_dia_spinner_title, null);
    s = (Spinner) findViewById(R.id.add_dia_t);
    ArrayAdapter<CharSequence> adapterS = ArrayAdapter.createFromResource(this,
            R.array.trainings, R.layout.spinner_item);
    adapterS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    s.setAdapter(adapterS);
    s.setOnItemSelectedListener(this);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.a_add)
    //set the View for the spinner
    .setCustomTitle(v)
    .setMultiChoiceItems(diaTitle, null,
            new DialogInterface.OnMultiChoiceClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which,
                boolean isChecked) {
            if (isChecked) {
                // If the user checked the item, add it to the selected items
                mSelectedItems.add(which);
            } else if (mSelectedItems.contains(which)) {
                // Else, if the item is already in the array, remove it 
                mSelectedItems.remove(Integer.valueOf(which));
            }
        }
    })
    // Set the action buttons
    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) { }
    })
    .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) { }
    });
    return builder.create();
}
I hope someone nows a solution or a better way, because this way seem quite complicated for me (and does not even work). Thanks!
 
     
     
    