views:

46

answers:

2

I want to dynamically add image in EditText. Is it possible? anybody knows please give sample code for that.

A: 

If something like this:

EditCheck

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
@Thanks Cassey,i want to dynamically add image in edit text using coding
sivaraj
I updated my answer to show how to do this in code.
CaseyB
java java command should call setBounds(Rect),or it canot appear image
pengwang
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
@Thanks sami,I want to add image in edit text dynamically,
sivaraj