I have an array of ImageSpan type which contains icons that were added to a TextEdit. It is called: ImageSpan[] itemSpans;
When I want to know which icon was typed in the EditText field - I loop through the array
for (int x = 0; x < itemSpans.length; x++) {
String Icon="";
if (itemSpans[x].getDrawable().equals(MyWinkIconImageView.getDrawable())) {
Icon = ":-)";
}
}
MyWinkIconImageView is a variable linked to ImageView control that points to a resource, Eg: R.Drawable.MyIcon
This is how how do it. Even if it is a bit wrong.
The thing is: I want to get the drawable's resource name from itemSpans[x].getDrawable() instead of pointing to the ImageView control, meaning that I want to know which itemSpans[x] is currently drawn in the EditText rather than to check its ImageView.
I wish to do something like that:
if (itemSpans[x].getDrawable().equals(R.Drawable.Smiley)
{
Icon=":-)";
}
if (itemSpans[x].getDrawable().equals(R.Drawable.Sad)
{
Icon=":-(";
}
and so on...
Again, the itemSpans[x].getDrawable()
array contain the image resources (icons from R.Drawable.xxxx
) that currently exist in the EditText after the user typed them. I just don't know how to get the R.drawable.xxxx
resource name from itemSpans[x]
in order to compare them like I mentioned above.