0

I m developing an application where i need to insert image buttons inside edit text window. On clicking particular image button it should get inserted at cursor of edit text.

How can i do this? Thanks in advance .

Tejaswini
  • 357
  • 4
  • 15

1 Answers1

1

You can do something like this:

EditText text = (EditText)findViewById(R.id.text);
text.setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.xyz), null);

Or something like android:drawableRight in the layout as explained here

HandlerExploit
  • 8,131
  • 4
  • 31
  • 50
Rahul garg
  • 9,202
  • 5
  • 34
  • 67
  • But this will place image button at right most of edit text. not at cursor – Tejaswini Jan 28 '12 at 16:10
  • I haven't tested it , but setCompoundDrawablesWithIntrinsicBounds() this might work to wrap image around the text in it.. – Rahul garg Jan 28 '12 at 19:24
  • i had tried it earlier...but of no use ..it just sets where it is to be appeared in edit text..not at cursor position – Tejaswini Jan 29 '12 at 02:09
  • thanks fr giving time but this was not what i was looking for.I want to insert smileys(image button) after chat text(in edit text)..I needed code for it. – Tejaswini Jan 29 '12 at 09:54