Error: Reached End Of File While Parsing
I am trying to build a login activity using android studio. They error keeps appearing and I don't know what to do about it. I have used } and still the last } has a red underlini
Solution 1:
You are not closing the setOnClickListener properly
and you are missing one '}'
` @OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Locate the button in activity_main.xmlButtonbutLogin= (Button) findViewById(R.id.butLogin);
// Capture button clicks
butLogin.setOnClickListener(newDialogInterface.OnClickListener() {
publicvoidonClick(View arg0) {
Intentintent= getIntent();
Stringvalue= intent.getStringExtra("key"); //if it's a string you stored.
}
publicvoidonClick(View v) {
if (checkPassword()) {
//Succeed: Load GameActivity.IntentmyIntent=newIntent(MainActivity.this,
GameActivity.class);
startActivity(myIntent);
} else {
//Fail: display error message.AlertDialogalertDialog=null;
alertDialog.setMessage("Alert message to be shown");
}
} // end of onClick method block
*});* // end of DialogInterface.OnClickListener block
} // end of onCreate block
}// end of class block`
Look at the end of DialogInterface.OnClickListener block
you are missing a );
Post a Comment for "Error: Reached End Of File While Parsing"