Dialog inherited in Android causes program to crash

Source: Internet
Author: User

============ 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.