Q:

How to dynamically bind list to Alert box in Android?

Hi im new to android development in want to bind array dynamically to alertbox in android i use the following code :
  //Return List of file in current directory from ftp//
  String[] ListFile =  Utility.GetFileFromFtp(Type.Contacts);

  AlertDialog.Builder builder1 = new AlertDialog.Builder(con); 
  builder1.setTitle("Select file to Restore");
  builder1.setSingleChoiceItems(ListFile ,-1,new DialogInterface.OnClickListener() {     //@Override
 public void onClick(DialogInterface dialog, int which) {
  // TODO Auto-generated method stub

                   //Error Line//       
  Log.d("FileName",String.valueOf(ListFile[which]));
      }
     });

      AlertDialog alert = builder1.create();  
      alert.setButton("Ok", OnClickListener);  
      alert.show();

this code bind the list to alert box sucessfully .
but when i attempt to get the filename which is selected by the user on onclick Event of the alertbox item
Code:
public void onClick(DialogInterface dialog, int which) 
{

                   //Error Line//       
  Log.d("FileName",String.valueOf(ListFile[which]));
      }
     });

it give error that 
Error:
Change the ListFile modifier to final

When i change the modifier to final i cant assign list dynamically.
i have no idea to resolve this issue,any help in this regard is greatlly appreciated.
thanks in advance.

A:

Declare ListFile as Public array then check it.
i think it will work.

