Hesam
Hesam

Reputation: 53610

Android, Configuring click listener for frame layout

as you can see in following screen shot of my program, the screen includes several frames and each frame has two image views and a text view. I want another activity starts, when user clicks on a frame (or imageView or textView).

In code, I have written:

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

but when I add following code, program crashes!

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

Upvotes: 3

Views: 8779

Answers (1)

necixy
necixy

Reputation: 5064

Try to comment the following line:

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

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

Upvotes: 2

Related Questions