2014-07-11 1 views
0

ProgressUpdateListener :안드로이드 방법에 의해 인터페이스 참조를 전달하는 의도

public interface ProgressUpdateListener { 
     public void on_update(int downloaded_size); 
} 

FileDownloader 방법 writeToParcel에서 리스너를 참조하여 처리 할 수있다

public class FileDownloader implements Parcelable { 
    ProgressUpdateListener listener; 

    public FileDownloader(ProgressUpdateListener listener) { 
     this.listener = listener; 
    } 


    @Override 
    public void writeToParcel(Parcel dest, int flags) { 
    // how to write listener? 
    } 
} 

내 질문 .. ??

+0

인터페이스를 추가하여 클래스에서이 인터페이스를 구현해야 인스턴스화 만되어 구현 될 수 있습니다. 클래스에이 인터페이스를 구현해야합니다. –

+0

concreate 인스턴스가 Serializable을 구현하게하고, 오브젝트를 번들 안에 넣고, Parcelable에 쓸 수도 있습니다. 나는 그것이 작동하는지 모르겠다. – Blackbelt

답변

-2

인터페이스는 단지 구현 될 수 인스턴스화 할 수 없습니다, 당신은 '할 수

은 다음과 같이 수행하고, 유엔 구현 방법뿐만 아니라

public class FileDownloader implements Parcelable,ProgressUpdateListener {