Hi all I am having some trouble starting up a new activity from my initial activity even though it is shown in code to be right. In practise, all that happens is that the button is clicked and everything stays the same. BTW this is only one way I have yet to implement a reverse way just relying on the back button.
Here is the code I am currently using.
AndroidManifest.xml
mainmenu.java
mainmenu.xml
underground.java
If anyone could help me figure out what is going wrong here, it would be greatly appreciated.
Thanks
Here is the code I am currently using.
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.transport.assistant"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:enabled="true"
android:debuggable="true">
<activity android:name="mainmenu"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="underground"></activity>
<activity android:name="splashscreen"></activity>
</application>
</manifest>
mainmenu.java
Code:
package com.transport.assistant;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class mainmenu extends Activity {
/** Called when activity is initially created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// click-handlers for buttons
Button underground = (Button)findViewById(R.id.ButtonM1);
underground.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent explicitIntent = new
Intent(mainmenu.this, underground.class);
startActivity(explicitIntent);
}
});
}
}
mainmenu.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:id="@+id/textView1"
android:text="@string/main_menu"
android:layout_height="wrap_content">
</TextView>
<Button
android:id="@+id/ButtonM1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Underground">
</Button>
<Button
android:id="@+id/ButtonM2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Bus">
</Button>
<Button
android:id="@+id/ButtonM3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/oyster_locations">
</Button>
<Button android:id="@+id/ButtonM4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/plan_journey">
</Button>
<Button
android:id="@+id/ButtonM5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Settings">
</Button>
</LinearLayout>
underground.java
Code:
package com.transport.assistant;
import android.app.Activity;
import android.os.Bundle;
public class underground extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.underground);
}
}
If anyone could help me figure out what is going wrong here, it would be greatly appreciated.
Thanks