public void onCreate(Bundle savedInstanceState) {
...
btn_client_connect.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
// inline implementation goes here ...
}
}
I want to move inline implementation to separate function, keeping onCreate function short and readable:
private void OnBtnConnectClick(View v) {
// implementation...
}
Now I need to subscribe to the button click using something like:
btn_client_connect.setOnClickListener(this.OnBtnConnectClick);
But this is not compiled. I only have this ugly solution:
btn_client_connect.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
OnBtnConnectClick(v);
}
});
Is there better way to do this?
there are other ways to set
Click Listenerslike oneyou simply type in xml
android:onClick="OnBtnConnectClick"and other as
Keppilsuggest