2011-10-19 7 views
0

비 활동 클래스에서 비트 맵을로드하려고 시도했지만 지금까지 한 모든 작업이 실패했습니다. Context를 참조로 보내려고했지만 오류가 발생합니다.비 활동 클래스의 getResources

내 현재의 상황은 다음과 같습니다

// Surface class 
public class GameScreen extends SurfaceView implements Callback { 
    TileSet ts; 

    public GameScreen(Context context, AttributeSet attr) { 
     // Here I send context as a reference 
     ts = new TileSet(context, R.drawable.tiles); 
    } 
} 


// This is the class I need to get resources 
public class TileSet { 
    public TileSet(Context context, int id) { 
     Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), id); 

    } 
} 

어떤 아이디어?

답변

1

Activity에서 비트 맵을 가져 와서 GameScreen의 생성자로 전달 했습니까?

+0

나는 그것을 생각했지만 다른 더 나은 해결책이 있기를 바랐다. 글쎄, 나는 그것을 시도 할 것이다. 아마 작동 할 것이다 ... 감사한다. – Lucas

+0

이것은 일을하는 데있어서 반드시 비범 한 방법은 아니다. . 또한 내 대답이 좋다고 생각되면 upvote 및/또는 동의하십시오. –

관련 문제