Klar kann ich den Quelltext liefern,
Habe um alle Fehler auszuschliessen ein komplett neues Projekt erstellt mit gleichem Fehler.
Ich denke mal das ICH da irgend was falsch mache.
Also das ist die Main: (von hier aus kann ich die 2te Seite aufrufen)
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;import android.view.View;
public class MainActivity extends Activity {
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);
}
@Overridepublic boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;
}
public void testklick (View view){setContentView(R.layout.activity_over);
}
}
Alles anzeigen
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="30dp"
android:layout_marginTop="132dp"
android:onClick="testklick"
android:text="Button" />
</RelativeLayout>
Alles anzeigen
und die 2te Seite:(von hier aus kann ich nicht auf die erste zurück allerdings koennte die Methode auch leer sein er wirft vorher die besagte Meldung raus)
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;import android.support.v4.app.NavUtils;
public class OverActivity extends Activity {
@Overrideprotected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);setContentView(R.layout.activity_over);
// Show the Up button in the action bar.
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}.
*/private void setupActionBar() {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Overridepublic boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.over, menu);return true;
}
@Overridepublic boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//NavUtils.navigateUpFromSameTask(this);return true;
}return super.onOptionsItemSelected(item);
}
public void test2klick(View view){setContentView(R.layout.activity_main);
}
}
Alles anzeigen
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".OverActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="46dp"
android:layout_marginTop="74dp"
android:onClick="test2klick"
android:text="Button" />
</RelativeLayout>
Alles anzeigen
Danke euch fürs drüberschauen