I have this main class which displays a button and on click of the
button, the NextActivity class should be called. I have defined the
NextActivity class in the same package. But when I click the button,
the application closes stating there is some error.
But when i directly start an intent (un comment the last line). The
application goes there without displaying the Main class. Please let
me know what is the mistake i am doing.
package com.intents;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainClass extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnOpen = (Button) findViewById(R.id.btnNext);
btnOpen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getBaseContext(),
"You have clicked the Open button",
Toast.LENGTH_SHORT).show();
Intent i = new Intent();
i.setClassName("com.intents", "NextActivity");
startActivity(i);
}
});
//startActivity(new Intent( this, NextActivity.class));
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
To unsubscribe from this group, send email to
android-developers+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.