java.lang.IllegalStateException: Could not find a method sendmessage(View) in the activity class
Main issue for the crash is due to the method name.
Change sendmessage
to sendMessage
on button onClick
onClick= "sendMessage"
There are more Issue in the DisplayMessageActivity
.Your trying to add the Fragment
to a container , which is not in the Activity
content View, since you have set the TextView
as ContentView
If your aim is to only show the TextView
, then remove the code adding the PlaceholderFragment
, also don't set any layout.
Change it as below.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
//create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
//Set the text view as the activity layout
setContentView(textView);
}
If your aim is to set the detail message to the TextView
in the Layout
, then find the TextView using its Id
and then set the text.