I have separate file with listener.
I want to attach that listener to button, using xml Android:onClick, but after compilling i get error
01-11 14:35:35.560: E/AndroidRuntime(4682): java.lang.IllegalStateException: Could not find a method Btnlistener(View) in the activity class com.android.app.Activity for onClick handler on view class android.widget.Button with id 'btn1'
Is there any fancy way to import my listener class, in such way that i could use Android:onClick in xml.
Here is what I suggest:
Have a
BaseActivitywith the code for your listener, in a normal methodAnd make all your activities that need this listener
extends BaseActivity. You can define in your layouts the following xml element for buttons: