Skip to content Skip to sidebar Skip to footer

Android - Game Thread And Dialogs

I have a Android game w/ a ViewThread and a Panel that uses the onTouchEvent. What's the best way to call the parent Activity's 'showDialog' method when the Panel's onTouchEvent is

Solution 1:

you can pass the context from parent activity

for example

showLongMessage(myclass.this, returnMsg);

and this is the showLongMessage method...

publicstaticvoidshowLongMessage(Context ctxtform, CharSequence message) {
    newAlertDialog.Builder(ctxtform)

    .setTitle(Modules.AgentName)

    .setMessage(message)

    .setIcon(R.drawable.icon_alert)

    .setPositiveButton("OK", newDialogInterface.OnClickListener() {

        publicvoidonClick(DialogInterface dialog, int whichButton)

        {

        }
    }).show();
}

Post a Comment for "Android - Game Thread And Dialogs"