public class DownloadActivity extends ListActivity{
private Thread thread; //스레드
TextView tv;
String fileName [];
String Server;
String ID;
String PassWord;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.download);
Intent intent=getIntent(); //인텐트를 통해 각각의 값들을 받아옴
String Server =intent.getStringExtra("data_ServerAddress"); //서버이름
String ID =intent.getStringExtra("data_ID"); //ID
String PassWord =intent.getStringExtra("data_PassWord"); //패스워드
String TimeOut =intent.getStringExtra("data_TimeOut"); //타임아웃
//String []items=new String[10000];
//ArrayList<String> al = new ArrayList<String>();
//ArrayList<String> items = new ArrayList<String>();
thread =new Thread(null,doBackgroundProcessing,"Background");//다운로드속도를 측정하는 스레드 설정
thread.start();//스레드 시작
}
public void onListItemClick(ListView l,View v,int position, long id){
//tv.setText(items[position]+"클릭됨");
}
private Runnable doBackgroundProcessing = new Runnable(){//속도측정 스레드
public void run(){//스레드 시작
try{
FTPClient con = new FTPClient();
con.connect("ftp.imrc.kist.re.kr", 21);//서버접속
con.login("gre_kist", "gre1003");
con.enterLocalPassiveMode(); //패시브모드로 전환합니다.
con.setFileType(con.BINARY_FILE_TYPE); //파일형식을 이진파일 형식으로 설정합니다.
con.changeWorkingDirectory("/");
FTPFile[] files=con.listFiles();
ArrayList<String> items = new ArrayList<String>();
for(int i=0; i<files.length; i++){
fileSize=Long.toString(files[i].getSize())+"bytes";
items.add(files[i].getName()+fileSize);
}
Log.v("HES", "Settings SUCCESS!!");
}catch (Exception e) //예외처리
{
e.printStackTrace();
}
ArrayAdapter<String>aa=new ArrayAdapter<String>(DownloadActivity.this,R.layout.downloadrow,R.id.label,items);
setListAdapter(aa);
tv=(TextView)findViewById(R.id.selection);
}
};
}




쓰레드 안에 try 부분을 처리하다가 에러가 발생하게 되면 items 같은 변수는 초기화가 안 되어 있는 상태일수도 있는데 밑에 부분에서 무조건 처리하시는 로직에서 에러가 발생할 수 있을꺼 같습니다.
또한 쓰레드에서 직접 ui쪽에 상태변경은 안됩니다. 그런건 Handler를 통해서만 UI 컴포넌트에 상태가 변경가능합니다.