Hi all,
I have a TextView in a ScrollView. Within the TextView there are
instructions on how to walk to a particular destination (like Google
maps directions). What I want to do is display an image before the
line of instruction.
E.g: [image here] Turn to left.
I use html imageGetter to accomplish this, however I fail to display
the image, I've tried many different implementations and none of them
works =( What I get
I'm so disappointing now, because on the Internet everybody seems to
have it working!
Below some codes I'm using:
ImageGetter imageGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
Drawable drawFromPath;
int path = Route.this.getResources().getIdentifier(source,
"drawable","com.prj56.tracingapp");
drawFromPath = (Drawable)
Route.this.getResources().getDrawable(path);
drawFromPath.setBounds(0, 0,
drawFromPath.getIntrinsicWidth(), drawFromPath.getIntrinsicHeight());
return drawFromPath;
}
};
and calling it with:
directions += Html.fromHtml("<img src=\"smiley\">", imageGetter, null)
+ " Turn to left\n";
My other (attempts of) implementations of imageGetter:
ImageGetter imageGetter2 = new ImageGetter() {
public Drawable getDrawable(String source) {
Drawable d = null;
d = Drawable.createFromPath(source);
d.setBounds(0,0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
};
ImageGetter imageGetter3 = new ImageGetter() {
public Drawable getDrawable(String source) {
int id=0;
if (source.equals("smiley")) {
id = R.drawable.smiley;
}
Drawable d = getResources().getDrawable(id);
d.setBounds(0, 0, d.getIntrinsicWidth(),
d.getIntrinsicHeight());
return d;
}
};
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en