android - Get different events on setCompoundDrawables with differnet drawables -
i have edittext in i'm setting drawables right of edittext. i'm switching drawables different scenarios. have cleartext , refreshicon drawables. these both changing correctly i'm not able separate events both of drawables. here i'm doing clearing text edittext:
string value = ""; final drawable x = getresources().getdrawable(r.drawable.clear_text); x.setbounds(0, 0, x.getintrinsicwidth(), x.getintrinsicheight()); geturl.setcompounddrawables(null, null, value.equals("") ? null : x, null); geturl.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { if (geturl.getcompounddrawables()[2] == null) { return false; } if (event.getaction() != motionevent.action_up) { return false; } if (event.getx() > geturl.getwidth() - geturl.getpaddingright() - x.getintrinsicwidth()) { geturl.settext(""); geturl.setcompounddrawables(null, null, null, null); } return false; } }); when click cleartext drawable clears text. nice , easy.
now, have drawable i.e. refreshicon, when on edittext refreshicon showing not getting particular event refresh purpose.
i have used same code of cleartext refreshicon. i'm not able print log when refreshicon clicked/touched.
what doing worong? kind of appreciated.
you can combine 2 drawables levellistdrawable. use setlevel function switch between them. can find out layer (drawable) visible via getlevel method , appropriate action.
Comments
Post a Comment