Reputation: 908
i have this code but every time i run the app and click on my button it crashes and i don't get why.. am i doing something wrong here any help would be great thanks
im trying to got to the "Sec.class" page/class
public class APPcalendarActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View continueButton = findViewById(R.id.continue_button);
continueButton.setOnClickListener( (OnClickListener) this);
}
//@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.continue_button:
Intent i = new Intent(this, Sec.class);
startActivity(i);
break;
}
}
THIS IS WHAT I WAS MISSING IN THE MANISFEST.XML FILE
and i want to slap the person who downgraded my question
<activity android:name=".Sec"
android:label="@string/sec" >
</activity>
Upvotes: 0
Views: 1131
Reputation: 111575
Check that you've declared an <activity>
tag for the Sec
activity in your AndroidManifest.xml
.
But posting (or simply reading) the crash stacktrace from logcat
would be more instructive.
Upvotes: 1
Reputation: 31846
Without knowing what the error is, it is really hard to guess what the problem is, but usually when this happens, the button (continueButton
in your case) could not be found in the layout. So make sure that you have a View with id continue_button
in main.xml
.
Upvotes: 0