开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜