i am working on an app in which user choose an image from gallery and it will be added in editText, now i want if user click on image in editText it should open in fullScreen, i used below code :-
public void addToEdt(Bitmap bitmap){
SpannableString ss = new SpannableString("abc");
Drawable d = new BitmapDrawable(getResources(), bitmap);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, 0, 3, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
edt_note.setTransformationMethod(null);
edt_note.getText().insert(edt_note.getSelectionStart(), ss);
final int start = ss.getSpanStart(span);
final int end = ss.getSpanEnd(span);
ClickableSpan click_span = new ClickableSpan() {
@Override
public void onClick(View widget) {
Toast.makeText(getApplicationContext(),"Clicked",Toast.LENGTH_LONG).show();
}
};
ClickableSpan[] click_spans = ss.getSpans(start, end, ClickableSpan.class);
if(click_spans.length != 0) {
// remove all click spans
for (ClickableSpan c_span : click_spans) {
ss.removeSpan(c_span);
}
}
ss.setSpan(click_span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
tried above code but its not listening onClick event, now, how can i listen click event on this image and do further task?
Clickable Span at the same start and end locations of the editText.
Also
I cannot write the whole code for you. Try the below sample:-