I have a horizontal scroll view, with several imageviews inside of it. If I click once on the images, I want to show a toast. This toast has to be changed depending on a stringvariable that is set in a textview.
If there is a doubleclick on an image, I need to open a new activity that opens a PDF (embedded into the app).
At the moment I have:
public class activity_fruit extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Fruit");
setContentView(R.layout.activity_fruit);
textView = (TextView) findViewById(R.id.txtstatus);
textView.setText(((Globals) this.getApplication()).getTaal());
int fruit1 = R.drawable.kumato;
ImageView targetImageView1 = findViewById(R.id.img_fruit1);
targetImageView1.setOnClickListener(new DoubleClickListener() {
@Override
public void onSingleClick(View v) {
if(textView.equals("ENG")) {
Toast.makeText(getApplicationContext(), "eng single", Toast.LENGTH_SHORT).show();
}
if (textView.equals("")) {
Toast.makeText(getApplicationContext(), "nl single", Toast.LENGTH_SHORT).show();
}}
@Override
public void onDoubleClick(View v) {
Toast.makeText(getApplicationContext(), "double", Toast.LENGTH_SHORT).show();
}
});
Glide.with(this)
.load(fruit1)
.into(targetImageView1);
Everything loads just fine, but since adding the if statement to my onSingleClick(), the one tap doesn't work anymore. The double tap works just fine.
As said in the first few lines of this post, I also want to change my double tap code to open a new activity and then open a PDF (that is stored in the app itself) inside the app itself. So any help with that would also be appreciated.
Aucun commentaire:
Enregistrer un commentaire