How should onClick Listener by defined and instantiated for an Activity

Posted by Code Droid on Stack Overflow See other posts from Stack Overflow or by Code Droid
Published on 2012-09-22T01:58:10Z Indexed on 2012/09/22 3:37 UTC
Read the original article Hit count: 115

Filed under:

My Activity has multiple lists so I have defined MyClickListener as below:

My question is how I should instantiate this class:

 MyClickListener mMyClickListener = new MyClickListener();

Or maybe it is better to instantiate inside the onCreate(Bundle) and just define above. Whats considered the better way? I don't want too much in onCreate() its already full of stuff. Any thoughts on the declaration and instatiation? Whats the best way?

private class MyClickListener implements OnClickListener
{

    @Override
    public void onClick(View view) {

    }

}

© Stack Overflow or respective owner

Related posts about android