Error Message On Main Activity: 'illegal Start Of Expression'
I'm trying to build a simple application where if a user inputs a text message and clicks a button, the message shows on the next view. It used to work fine, but then I added some
Solution 1:
Please close your onCreate method.
publicclassMainActivityextendsActionBarActivity {
publicfinalstaticStringEXTRA_MESSAGE="com.yhmac.myapplication3.MESSAGE";
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/** Called when the user clicks the Send button */publicvoidsendMessage(View view) {
// Do something in response to buttonIntentintent=newIntent(this, IntroToApp.class);
EditTexteditText= (EditText) findViewById(R.id.edit_message);
Stringmessage= editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
Solution 2:
It should be like this.
publicclassMainActivityextendsActionBarActivity {
publicfinalstaticStringEXTRA_MESSAGE="com.yhmac.myapplication3.MESSAGE";
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/** Called when the user clicks the Send button */publicvoidsendMessage(View view) {
// Do something in response to buttonIntentintent=newIntent(this, IntroToApp.class);
EditTexteditText= (EditText) findViewById(R.id.edit_message);
Stringmessage= editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
Solution 3:
Try this. Hope it will work.
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/** Called when the user clicks the Send button */publicvoidsendMessage(View view) {
// Do something in response to buttonIntentintent=newIntent(this, IntroToApp.class);
EditTexteditText= (EditText) findViewById(R.id.edit_message);
Stringmessage= editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
Post a Comment for "Error Message On Main Activity: 'illegal Start Of Expression'"