Reputation: 1710
I have EditText with InputType of password and one ImageView like a button. So I want when user hold his finger on that image, InputType of EditText to become normal text, and when user remove finger, InputType again to be password. So how can I do this?
Upvotes: 0
Views: 97
Reputation: 923
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
imageView.setOnTouchListener(new View.OnTouchListener {
public onTouch(View v, MotionEvent event){
if (event.getAction() == MotionEvent.ACTION_DOWN)
{
//set edittext to normal
}
else if (event.getAction() == MotionEvent.ACTION_UP
{
// set edittext to password
}
return true;
}
});
The above code should work, it might need a little tweaking - I can't test it at the moment. Should give you a good idea on how to handle it.
Upvotes: 1
Reputation: 866
You can do a setOnTouchListener on the Image
and inside you can call the setInputType of the EditText
. Just report to this link to see wich setInputType
parameter suits you the most.
Upvotes: 1