Reputation: 1570
I have found the following code where i can add an image within a Textview with the help of SpannableStringBuilder. I would also like to add a EditText field within the textview, just like how image is added below. I'm struggling with this from a lot of time. Thanks in advance
TextView textView = (TextView) findViewById(R.id.textView);
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append("My string. I ")
.append(" ", new ImageSpan(getActivity(), R.drawable.ic_action_heart), 0)
.append(" Cree by Dexode");
textView.setText(builder);
As you can see in the Picture attached, image was successfully spanned within the textview. Similarly I would like to an EditText field within Textview
Upvotes: 1
Views: 285
Reputation: 3454
You cannot attach another View
inside a View
. Remember that ImageSpan
is not a ImageView
but a Bitmap
drawn inside TextView
just like texts..
If you wish to let user input inside your view you Should use a EditText
along TextWatcher
or Simply Position a EditText
over your TextView
.
Upvotes: 1