Android Developer 사이트에 보면 다음과 같은 체크박스와 라디오버튼을 사용한 single choice dialog 만들기에 대한 페이지가 있습니다(http://docs.androidside.com/docs/guide/topics/ui/dialogs.html).

final CharSequence[] items = {"Red", "Green", "Blue"};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setTitle("Pick a color");
builder
.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
   
public void onClick(DialogInterface dialog, int item) {
       
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
   
}
});
AlertDialog alert = builder.create();

저는 어떤 이미지를 touch했을 때 이같은 single choice dialog가 뜨도록 만들고 싶습니다만, OnItemClick 함수를 만들어 위 코드를 집어넣은 결과 아무 반응이 없었습니다. 왠지 이유는 아직 찾지 못했습니다. 코드를 첨가해 보이면

public class Function1 extends Activity {


    Integer[] imageIDs = {
            R.drawable.department1,
            R.drawable.department2,
            R.drawable.department3                    
    };
 
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.function);
        Gallery gallery = (Gallery) findViewById(R.id.gallery1);
       
        gallery.setAdapter(new ImageAdapter(this));       
        gallery.setOnItemClickListener(new OnItemClickListener()
        {
            public void onItemClick(AdapterView parent,View v, int position, long id){
              
            final CharSequence[] items = {"Red", "Green", "Blue"};

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setTitle("Pick a color");
builder
.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
   
public void onClick(DialogInterface dialog, int item) {
       
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
   
}
});
AlertDialog alert = builder.create();

               Toast.makeText(getBaseContext(), "department" + (position +1) + " selected",
                       Toast.LENGTH_SHORT).show();
            }
        });
    }

ImageAdapter 함수는 생략했습니다. 저의 질문은 어느 부분이 잘못되어 이 다이얼로그가 생성되지 않는가 하는 것입니다. 물론 run은 문제가 없습니다. 마지막 부분에 있는 toast는 또 정상적으로 실행이 되구요.
코드상의 문제점을 발견하실 수 있는 고수님들 혹시 지적이 가능하시다면 부탁드립니다. 아니면 이미지를 click했을 때 리스트 중 하나의 아이템을
선택해서 그 아이템이 toast에 나타나게끔 하는 다이얼로그를 만들어 주실 수 있으신지요?