开发者

Android, Configuring click listener for frame layout

开发者 https://www.devze.com 2023-03-06 13:59 出处:网络
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.

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 anoth开发者_开发知识库er 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

Android, Configuring click listener for frame layout


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

0

精彩评论

暂无评论...
验证码 换一张
取 消