android - to change the drawable right of an edit text -
i'm trying change drawable in edittext in image.
i'm using following code make drawable clickable.
password_edittext.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { final int drawable_left = 0; final int drawable_top = 1; final int drawable_right = 2; final int drawable_bottom = 3; if (event.getaction() == motionevent.action_up) { if (event.getrawx() >= (password_edittext.getright() - password_edittext .getcompounddrawables()[drawable_right].getbounds() .width())) { // action here toast.maketext(mainactivity.this, "drawable click", toast.length_long).show(); return true; } } return false; } });
in change drawable in password column changed on clicking.
you can change drawable @ runtime using
drawable img = getcontext().getresources().getdrawable( r.drawable.your_drawable ); password_edittext.setcompounddrawables( null, null, img, null );
Comments
Post a Comment