I created two activities. If i hold an imageview i want to start the new activity but it doesn´t recognize in the new activity that it is still being held.
MainActivity
public class MainActivity extends AppCompatActivity {
ImageView imageView1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView1 = (ImageView) findViewById(R.id.imageView);
imageView1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN) {
Intent i = new Intent( MainActivity.this, FullActivity.class);
startActivity(i);
}
return false;
}
});
}
}
Second Activity
public class FullActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_full);
ImageView imageViewFull;
imageViewFull = (ImageView) findViewById(R.id.imageViewFull);
imageViewFull.setImageResource(R.mipmap.ic_launcher);
imageViewFull.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()== MotionEvent.ACTION_UP){
finish();
}
return true;
}
});
}
}
Also my funtion to make the titlebar disappear doesn`t work.
A touch event triggers by touching the screen, not by holding it down.