I am having difficulty in showing a specific item on a map.
When user clicks a point I want to place an object with a counter on top.
I was thinking in using a text view and converting it in a drawable, using this method but it does not work.
What i tried looks like this :
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout ... >
<TextView
android:id="@+id/object"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableBottom="@drawable/car"
android:text="Human 1,2..." /> <!-- Here should be the counter modified programatically -->
</LinearLayout>
code:
public boolean onTouchEvent(MotionEvent e, MapView m) {
....
CustomPinPoint custom = new CustomPinPoint(getHuman(), Main.this);
}
private Drawable getHuman() {
Bitmap snapshot = null;
Drawable drawable = null;
LayoutInflater li = Main.this.getLayoutInflater();
View view = li.inflate(R.layout.human, null); //human is the layout
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
try {
snapshot = Bitmap
.createBitmap(view.getDrawingCache());
drawable = new BitmapDrawable(snapshot);
} finally {
view.setDrawingCacheEnabled(false);
}
return drawable;
}
Currently, i get null pointer at Bitmap.createBitmap(view.getDrawingCache());
. Tried it with dimensions, still no success. Can someone tell me what am I doing wrong? Or if there is another approach to getting drawable from text view?
Thanks in advance, Cosmin.