Button.setOnClickListener doesn't work?

Posted by user164589 on Stack Overflow See other posts from Stack Overflow or by user164589
Published on 2010-03-28T08:40:04Z Indexed on 2010/03/28 8:43 UTC
Read the original article Hit count: 206

Filed under:

Hi guys,

I am trying to make a button using programmable way.

My code is :

Button mybutton = new Button(this);
mybutton.setText("My Button");
linearLayout.addView(mybutton, 3);
mybutton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Log.println(Log.ERROR, "MyApp", "Clicked on the button.");
    }
});

But its setOnClickListener doesn't work.

What is wrong for me ?

Please help.

Thanks.

© Stack Overflow or respective owner

Related posts about android