I want to dynamically add image in EditText
. Is it possible? anybody knows please give sample code for that.
views:
46answers:
2
A:
If something like this:
is what you're talking about, then you just need to either set the Drawable{Right | Left | Top | Bottom}
property in the xml, or call the corresponding java command.
EditText text = (EditText)findViewById(R.id.text);
text.setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.check_box), null);
CaseyB
2010-09-13 21:25:23
@Thanks Cassey,i want to dynamically add image in edit text using coding
sivaraj
2010-09-14 08:20:47
I updated my answer to show how to do this in code.
CaseyB
2010-09-14 14:28:28
java java command should call setBounds(Rect),or it canot appear image
pengwang
2010-09-15 08:35:54
A:
Hi , you can add an image to your EditText through android:background="@drawable/img" if you want to modify the style by using nine patch or else , but if you want to add a small image in the left of your EditText think to use nandroid:drawableRight="@drawable/icon"
sami boussacsou
2010-09-13 21:29:12