SurfaceCreatedが呼ばれません。
コンストラクタは呼ばれているのですが、何故なのでしょうか?
Fragment側で操作してる内容は、
@Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
mSurfaceView = new AnimationSurfaceView(getActivity());
です。
Callbackを呼ばれるようにするには、SurfaceViewでimplementsするだけでいいのでしょうか?
java
1 2public class AnimationSurfaceView extends SurfaceView implements Runnable, SurfaceHolder.Callback { 3 4 5 public AnimationSurfaceView(Activity context) { 6 super(context); 7 8 Log.e(TAG,"AnimationSurfaceViewのコンストラクタが呼ばれた-"); 9 surfaceHolder = getHolder(); 10 11 FaceLine faceline=new FaceLine(); 12 faceline.setSurfaceHolder(surfaceHolder); 13 14 15 if(canvas!=null){ 16 Log.e(TAG,"canvasはnullじゃなかった"); 17 }else if(canvas==null){ 18 Log.e(TAG,"canvasはnullだった"); 19 } 20 21 22 surfaceHolder.addCallback(this); 23 24 surfaceHolder.setFormat(PixelFormat.TRANSLUCENT); 25 setZOrderOnTop(true); 26 27 28 } 29 30 public AnimationSurfaceView(Context context, AttributeSet attrs) { 31 this(context, attrs, 0); 32 } 33 34 public AnimationSurfaceView(Context context, AttributeSet attrs, int defStyle) { 35 super(context, attrs, defStyle); 36 } 37 38 39 40 @Override 41 public void surfaceCreated(SurfaceHolder holder) { 42 thread = new Thread(this); 43 thread.start(); 44 45 Log.e(TAG,"surfaceCreated()"); 46 47 } 48 49 @Override 50 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { 51 screen_width = width; 52 screen_height = height; 53 Log.e(TAG,"surfaceChanged"); 54 } 55 56 @Override 57 public void surfaceDestroyed(SurfaceHolder holder) { 58 thread = null; 59 Log.e(TAG,"surfaceDestroyed"); 60 } 61 62 @Override 63 public void run() { 64 65 Log.e(TAG,"runに入った"); 66 } 67} 68
Fragmentにimplementさせても、onviewCreatedなどが呼び出されません。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。