Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 518
Hesam Avatar asked Jan 29 '26 07:01

Hesam


1 Answers

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"?

like image 98
necixy Avatar answered Jan 30 '26 19:01

necixy