Android ImageView's onClickListener does not work

前端 未结 15 1805
情话喂你
情话喂你 2020-12-01 13:30

I have an ImageView for which I wanted to implement the onClickListener. But when I click on the image, nothing happens. Event the Logcat does not show any errors.

F

15条回答
  •  不思量自难忘°
    2020-12-01 14:30

    Please Try this one.

    ImageView imageview1 = findViewById(R.id.imageView1);
    imageview1.setOnClickListener(new View.OnClickListener() {
    
            @Override
    
            public void onClick(View v) {
    
                Toast.makeText(YourActivity.this, "Here is your Text",Toast.LENGTH_SHORT).show();
    
            }
    
        });
    

提交回复
热议问题