[Solved] How can I draw Map in Android Activity?


If you make each state have unique color, you can check the pixel color on the clicked point:

public boolean onTouch (View v, MotionEvent ev) 
{

    final int action = ev.getAction();

    final int evX = (int) ev.getX();
    final int evY = (int) ev.getY();

    switch (action) {
        case MotionEvent.ACTION_DOWN :
           break;
        case MotionEvent.ACTION_UP :
           ImageView img = (ImageView) findViewById (YOUR_IMG_DRAWABLE);
           img.setDrawingCacheEnabled(true); 
           Bitmap imgbmp = Bitmap.createBitmap(img.getDrawingCache()); 
           img.setDrawingCacheEnabled(false);

           int pxl = imgbmp.getPixel(evX, evY);

           int redComponent = Color.red(pxl);
           int greenComponent = Color.green(pxl);
           int blueComponent = Color.blue(pxl);

           break;
    }

}

And then depending on the color, check which state was clicked, and do whatever you need.

2

solved How can I draw Map in Android Activity?