में ऑन ड्रा() विधि में बिटमैप को तेजी से कैसे आकर्षित करें I एंड्रॉइड में एकल टैप विधि पर मार्कर आकर्षित करने का प्रयास कर रहा हूं। जब मैं मार्कर खींचता हूं तो यह आकर्षित होगा लेकिन 30-40 मिलीसेकंड को खींचने में अधिक समय लगेगा, इसमें 2-3 सेकंड लगते हैं। यहां कक्षा के लिए मेरा कोड है जिसमें मेरे पास विधि है।कैनवास एंड्रॉइड
public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> overlayItemList = new ArrayList<OverlayItem>();
public MyItemizedOverlay(Drawable pDefaultMarker,
ResourceProxy pResourceProxy) {
super(pDefaultMarker, pResourceProxy);
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean arg2) {
super.draw(canvas, mapView, arg2);
// ---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);
// ---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_darkblue);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_green);
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_bue);
Bitmap bmp3 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
Bitmap bmp4 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
Bitmap bmp5 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
Bitmap bmp6 = BitmapFactory.decodeResource(getResources(),
R.drawable.pin_annotation_light);
if (count == 1) {
int caller = getIntent().getIntExtra("button", 0);
switch (caller) {
case R.id.btMap:
canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 50, null);
bmp.recycle();
break;
case R.id.imageButton1:
canvas.drawBitmap(bmp1, screenPts.x, screenPts.y - 50, null);
bmp1.recycle();
break;
case R.id.imageButton2:
canvas.drawBitmap(bmp2, screenPts.x, screenPts.y - 50, null);
bmp2.recycle();
break;
case R.id.imageButton3:
canvas.drawBitmap(bmp3, screenPts.x, screenPts.y - 50, null);
bmp3.recycle();
break;
case R.id.imageButton4:
canvas.drawBitmap(bmp4, screenPts.x, screenPts.y - 50, null);
bmp4.recycle();
break;
case R.id.imageButton5:
canvas.drawBitmap(bmp5, screenPts.x, screenPts.y - 50, null);
bmp5.recycle();
break;
case R.id.imageButton6:
canvas.drawBitmap(bmp6, screenPts.x, screenPts.y - 50, null);
bmp6.recycle();
break;
}
}
// Bitmap bmp = BitmapFactory.decodeResource(getResources(),
// R.drawable.pin_annotation_green);
// if (count == 1) {
// canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 50, null);
// }
}
हमें [बातचीत में इस चर्चा को जारी रखें] (http://chat.stackoverflow.com/rooms/40102/discussion-between-gaurav- कुमार-and-yushulx) –
कोड साझा करने के लिए धन्यवाद। लेकिन मुझे नहीं लगता कि आपको पहले उदाहरण में स्विच की जरूरत है। बस यह करें: 'int caller = getIntent()। GetIntExtra ("बटन", 0); बिटमैप बीएमपी = mStore.get (कॉलर); canvas.drawBitmap (बीएमपी, screenPts.x, screenPts.y - 50, शून्य); bmp.recycle(); बीएमपी = शून्य; ब्रेक; } ' –