i am working on android.
i am creating a login button. i want that whenever i press login button then text color of that button should be changed.
and when this button pressed then login functionality should be performed.
for this i am coding like this:-
button_login.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
int action = arg1.getAction();
if(action == MotionEvent.ACTION_DOWN) {
button_login.setTextColor(Color.parseColor("#163D74"));
return true;
} else if (action == MotionEvent.ACTION_UP) {
button_login.setTextColor(Color.parseColor("#FFFFFF"));
return true;
}
return false;
}
});
button_login.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v)
{
// checking the functionality of login
}
});
but only onTouchListener is working. login functionality is not working.
please suggest me what mistake i have done. and how can i implement these both functionalities. means how can i change the color of text of button and how can i perform login functionality.
Thank you in advance.
You should just declare your login functionality when action is UP.
Its does the same thing with the same logic.