I have a relativelayout and are encoded onTouchListenerto highlight the background as follows:
relative3.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View arg0, MotionEvent event)
{
if(event.getAction()==MotionEvent.ACTION_DOWN )
{
relative3.setBackgroundColor(getResources().getColor(R.color.tran_grey));
}
if((event.getAction()==MotionEvent.ACTION_UP || event.getAction()==MotionEvent.ACTION_CANCEL))
{
relative3.setBackgroundColor(getResources().getColor(android.R.color.transparent));
}
return true;
}
});
and perform an action on onClick
relative3.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
custom_toast("Redirecting...");
}
});
Question:
Relativity can show highlighting ACTION_DOWNand return to transparency on ACTION_UP. However, it is clicked, the toast just does not appear as encoded.
How can this be changed? Thanks!
source
share