I want to add some text fields with image in edittext in android. I can add one text with an image in edittext in android using the following code.
ClickableSpan clickSpan = new ClickableSpan() {
@Override
public void onClick(View view) {
Log.v("clicked", view.getClass().getSimpleName());
}
};
final SpannableStringBuilder sb = new SpannableStringBuilder();
TextView tv = createContactTextView(contactname);
View view1 = getLayoutInflater().inflate(R.layout.contact_layout,null);
TextView tv1 = (TextView) view1.findViewById(R.id.contactName);
tv1.setText(contactname);
BitmapDrawable bd = (BitmapDrawable) convertViewToDrawable(view1);
bd.setBounds(0, 0, bd.getIntrinsicWidth(),bd.getIntrinsicHeight());
sb.append(contactname + ",");
sb.setSpan(new ImageSpan(bd), sb.length()-(contactname.length()), sb.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
autoCompleteTextView.setMovementMethod(LinkMovementMethod.getInstance());
sb.setSpan(clickSpan, sb.length(),
sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
autoCompleteTextView.setText(sb);
public TextView createContactTextView(String text){
TextView tv = new TextView(this);
tv.setText(text);
tv.setTextSize(20);
tv.setBackgroundResource(R.color.bubble);
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0,android.R.drawable.presence_offline, 0);
return tv;
}
public static Object convertViewToDrawable(View view) {
int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
view.measure(spec, spec);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
Bitmap b = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.translate(-view.getScrollX(), -view.getScrollY());
view.draw(c);
view.setDrawingCacheEnabled(true);
Bitmap cacheBmp = view.getDrawingCache();
Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
view.destroyDrawingCache();
return new BitmapDrawable(viewBmp);
}
In the above code, I have the following layout.

How can I add multiple text views with an image, such as the following layout?

I did this using autocompletetextview. After inserting a single text image with image view, the autocompletetextview clause is stopped. How can I start the autocompletetextview auto suggestion again? How can I insert multiple textview with image view in autocompletetextview?
2 :
user5617522