Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create Clickable Rectangles?
    primarykey
    data
    text
    <p>Im drawing an indoor map using DrawRect method. I want to identify each rectangle by the user's OnTouch Event.How can i make it happen?</p> <p>I want to know if i can use the drawn Rectangles as independent objects Where i can identify them uniquely.</p> <p><strong>UPDATED</strong></p> <p><strong>I tried this. But it gives me errors.How can i create a new intent withing the for loop?? :(</strong></p> <pre><code>ArrayList&lt;Rect&gt; rectangles = new ArrayList&lt;Rect&gt;(); {rectangles.add(new Rect(232,78,419,238)); rectangles.add(new Rect(285,27,524,239)); rectangles.add(new Rect(418,79,524,239)); rectangles.add(new Rect(181,79,233,215)); rectangles.add(new Rect(232,237,524,315));} String Selected_rect = null; public boolean onTouchEvent(MotionEvent event) { int touchX = (int) event.getX(); int touchY = (int) event.getY(); switch(event.getAction()){ case MotionEvent.ACTION_DOWN: System.out.println("Touching down!"); for(int i =0; i&lt; rectangles.size();i++){ if(rectangles.get(i).contains(touchX,touchY)){ System.out.println("Touched Rectangle, start activity."); rectangles.get(i).describeContents (); Selected_rect = String.valueOf(rectangles.get(i)); } // Intent inte = new Intent("android.intent.action.DetectBlock"); // startActivity(inte); } break; case MotionEvent.ACTION_UP: System.out.println("Touching up!"); break; case MotionEvent.ACTION_MOVE: System.out.println("Sliding your finger around on the screen."); break; } return true; } </code></pre> <p><strong>My Intent method body</strong> </p> <pre><code>private void startActivity(Intent inte) { // TODO Auto-generated method stub startActivity(inte); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload