I want to create an new image by touchscreen but it shows errors which I don't know reasons. It shows
The constructor ImageView(LinearLayout) is undefined
This is main activity:
public class MainActivity extends Activity {
public LinearLayout screenlayout;
public void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
setContentView(R.layout.activity_main);
final LinearLayout screenlayout= (LinearLayout)findViewById(R.id.screenlayout);
screenlayout.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
int x_cord = (int) event.getX();
int y_cord = (int) event.getY();
AddPicture aa = new AddPicture();
aa.addNewer(screenlayout, x_cord, y_cord);
break;
case MotionEvent.ACTION_MOVE:
break;
default:
break;
}
return true;
}
});
}
}
This is AddPicture Class:
public class AddPicture extends MainActivity{
public void addNewer(LinearLayout screenlayout,int vtx,int vty) {
ImageView i = new ImageView(screenlayout);
i.setImageResource(R.drawable.ball);
i.setAdjustViewBounds(true);
i.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
screenlayout.addView(i);
setContentView(screenlayout);
}
}