여전히 startUpload (position)를 호출하고 있습니다. 의 getView (...) {} 방법 방법,하지만 지금은이처럼클래스의 어디서나 사용할 수 있도록 메소드를 작성해야하는 방법
loginbutton.setOnClickListener(new View.OnClickListener() {....}
에 전화 싶어하지만 항상 내가 위치를 얻고 내가 알고 싶은, 그래서 여기에 변수 에 해결 될 수없는 내가 작성해야하는 방법을 방법은 수업 시간에 어디서든 사용 : 아래
loginbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SaveData();
alertDialog.dismiss();
startUpload(position);
}
는 방법, startUpload는 (...) {...}
//Upload
public void startUpload(final int position) {
Runnable runnable = new Runnable() {
public void run() {
handler.post(new Runnable() {
public void run() {
View v = lstView.getChildAt(position - lstView.getFirstVisiblePosition());
// Show ProgressBar
ProgressBar progress = (ProgressBar)v.findViewById(R.id.progressBar);
progress.setVisibility(View.VISIBLE);
// Status
TextView status = (TextView)v.findViewById(R.id.ColStatus);
status.setText("Uploading..");
new UploadFileAsync().execute(String.valueOf(position));
}
});
}
};
new Thread(runnable).start();
}
중복 가능성 [세계의 메소드를 선언하는 방법 (http://stackoverflow.com/questions/17421555/how-to-declare-method-globally-in-class) – jlordo
그래서 두 번은 말이 안된다. 'startUpload()'메소드는 도움이되지 않습니다. 'loginbutton.setOnClickListener (...);'에 대한 좀 더 자세한 내용을 보여주십시오. 오류 메시지는 매우 자명한데, 범위를 벗어나는 곳에'position'을 사용하려고합니다. 범위에 있다면 내부 익명 클래스가 액세스 할 수 있도록 'final'이어야합니다. 'onClick'에서 – jlordo
,'position'은 무엇입니까? –