CardGameActivity.java
package org.game;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class CardGameActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_card_game);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_card_game, menu);
return true;
}
}
CardGameView.java
package org.game;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.View;
public class CardGameView extends View{
Bitmap m_BackGroundImage;
public CardGameView(Context context){
super(context);
m_BackGroundImage = BitmapFactory.decodeResource(getResources(),
R.drawable.background,null);
}
@Override
public void onDraw(Canvas canvas){
canvas.drawBitmap(m_BackGroundImage, 0, 0,null);
}
}
불러올 이미지는 첨부해두었습니다..
png 파일이고.. 책에 나와있는데로 하고 실행했는데도
사진이 안뜨고 헬로월드 인가 그거만 뜨네요..
안드로이드 에뮬레이터 실행은
이클립스 주노
Devide 5.1 WVGA (480X800 mdpi)
Target android 4.1.2 api 16
cpu arm
뭐가 문제인가여...




xml을 보지 못하여서 모르겠지만 혹시 view는 생성하고 안붙이신거 아니신가요?
즉 activity_card_game에 CardGameView를 생성하지 않고 사용하신거 같습니다.
아니면 동적으로 생성해서 addview를 하시는것도 추천 합니다.