I am working on the Hello Android book Sudoku example and would like to create a congratulations dialog when the game is finished. In a game class I check if there are any blank squares and then in the PuzzleView
class I am trying to check if the game is solved. If the game is complete it should show the message but I am getting an error when I create the intent.
The constructor Intent(PuzzleView, Class<Congratulations>)
is undefined.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (game.isSolved()== true)
{
Intent i = new Intent(PuzzleView.this, Congratulations.class);
startActivity(i);
}
else
{
Log.d(TAG, "onKeyDown: keycode=" + keyCode + ", event="
+ event);
/*MORE CODE GOES HERE*/
Can anyone help please? EDIT:- I think the main problem that I am having is trying to startActivity in a class that extends View. Is there a way to do this?
1. Please check that PuzzleView
and Congratulations
classes have extended Activity .
2. Make sure that you have defined those Activities in your AndroidManifest.xml
file.
Thought you know it, but still i will show the Intent syntax....
Intent i = new Intent(Your_Current_Activity.this, Your_Desired_Activity.class);
startActivity(i);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.