When calling
public void onPress(int primaryCode) { startActivity(new Intent(MainActivity.this,swipe.class)); } This error comes out.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.lol.keyboard/com.example.lol.keyboard.swipe}: java.lang.InstantiationException: java.lang.Class<com.example.lol.keyboard.swipe> has no zero argument constructor swipe.class:
public class swipe extends View { public swipe(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onTouchEvent(MotionEvent event) { float touchX = event.getX(); float touchY = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_MOVE: MainActivity.coord.add(touchX); MainActivity.coord.add(touchY); } return true; }
swipeclass (the name of which for some reason starts with a small letter) does not have a constructor without parameters. Accordingly, either create such a constructor in theswipeclass, or do not use this code. And the class is still calledSwipe. - Regentcom.example.lol.keyboard.swipeclass as anActivity, although in fact it is a heir toView. You have to decide what you need - to start the activity or to insert the widget somewhere - woesss