android javaについて質問です public class MailMotion extends Activity implements OnTouchListener, OnClickListener { private FrameLayout frameLayout01; private ImageView target; private Button trash; private int targetLocalX; private int targetLocalY; private int screenX; private int screenY; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.motion); frameLayout01 = (FrameLayout)findViewById(R.id.FrameLayout01); target = (ImageView)findViewById(R.drawable.toudai); target.setOnTouchListener(this); trash = (Button)findViewById(R.id.trash); trash.setOnClickListener(this); } @Override public boolean onTouch(View v, MotionEvent event) { int x = (int)event.getRawX(); int y = (int)event.getRawY(); switch(event.getAction()) { case MotionEvent.ACTION_DOWN: targetLocalX = target.getLeft(); targetLocalY = target.getTop(); screenX = x; screenY = y; break; case MotionEvent.ACTION_MOVE: int diffX = screenX - x; int diffY = screenY - y; targetLocalX -= diffX; targetLocalY -= diffY; target.layout(targetLocalX, targetLocalY, targetLocalX + target.getWidth(); targetLocalY + target.getHeight()); screenX = x; screenY = y; break; case MotionEvent.ACTION_UP: int trashLeft = trash.getLeft() + trash.getWidth()/2; int trashTop = trash.getTop() + trash.getHeight()/2; int targetRight = target.getLeft() + target.getWidth(); int targetBottom = target.getTop() + target.getHeight(); if (targetRight > trashLeft && targetBottom > trashTop) { frameLayout01.removeView(target); } break; } return true; } @Override public void onClick(View v) { int childCount = frameLayout01.getChildCount(); if(childCount == 1) { frameLayout01.addView(target); }}} 上記のものを起動させると、nullpointが出てきます 前回の質問をもとに、デバッグをしてみたのですが、touchonLisnerのところでエラーが起きました 勉強不足なので原因がよくわかっておりません 間違いを教えていただけないでしょうか? stringは #ffff00 で設定して、おそらく大丈夫だと思います
↧