Android, setting up a click listener for frame layout

as you can see in the next screenshot of my program, the screen includes several frames, and each frame has two types of images and a textual representation. I want another action to start when the user clicks on the frame (either imageView or textView).

In the code, I wrote:

final FrameLayout frame01 = (FrameLayout) findViewById(R.id.frame01);

but when I add the following code, the program will work!

frame01.setOnClickListener(new View.OnClickListener() {         
            @Override
            public void onClick(View v) {
                Toast.makeText(Main.this, "Frame01 Selected", Toast.LENGTH_SHORT).show();
            }
        });

what should I do? Thanks

enter image description here

+3
source share
1 answer

Try commenting on the following line:

Toast.makeText(Main.this, "Frame01 Selected", Toast.LENGTH_SHORT).show();

Are you sure you have the current class name "Main.java"?

+2
source

All Articles