============ Problem Description ============
In a view of your own definition, a dialog box pops up when you tap the screen, and the result is forced to close each time the program is clicked.
The Ontouchevent () method in view:
public boolean ontouchevent (Motionevent event) {//log.i ("sudu002", "done!!!!!!!!!!!!!!!!!"); if (event.getaction ()! = event. Action_down) return super.ontouchevent (event); int x = (int) (EVENT.GETX ()/width); int y = (int) (Event.gety ()/height); int [] used = Game.getusedtilesbycoor (x, y),//log.i ("sudu002", "return Useddata" + used.length), for (int a:used) log.i ("Shudu ", A +" ");d Ialog = new Mydialog (GetContext (), used);d ialog.show (); return true;}
Self-Defined dialog:
public class Mydialog extends Dialog{private View keybutton[] = new View[9];p rivate int[] useddata = new Int[9];p ublic MyD Ialog (context context, int[] useddata) {super (context); this.useddata = Useddata;} @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Settitle ("123"); Setcontentview (R.layout.my_dialog);}}
============ Solution 1============
What is the exception message that is forcibly closed?
============ Solution 2============
Ask, can you determine int [] used = Game.getusedtilesbycoor (x, y); is the int array obtained must be a 9-element? , you declared private View keybutton[] = new view[9 in dialog);
Private int[] Useddata = new Int[9]; Is it because your next statement has a Keybutton traversal, causing two arrays to fail?
Dialog inherited in Android causes program to crash