F
FuNIID3X
Neues Mitglied
- 0
Hallo liebe Community Ich arbeite seit einiger Zeit an einer kleinen App für Android und versuche mich gerade an einer App mit einem Tabhoster (3 Tabs)
Beim Testen der App auf dem Emulator von Eclipse (AVD Manager) wird die App gleich nach dem Start wieder geschlossen: (Unfortunately, App has stopped). Was könnten mögliche Ursachen für das beenden der App sein? Vielen Dank schonmal für eure Hilfe
Hier die Quelltexte
AndroidManifest.xml
activity_main.xml
MainActivity.java
Beim Testen der App auf dem Emulator von Eclipse (AVD Manager) wird die App gleich nach dem Start wieder geschlossen: (Unfortunately, App has stopped). Was könnten mögliche Ursachen für das beenden der App sein? Vielen Dank schonmal für eure Hilfe
Hier die Quelltexte
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.FuNIID3X.plta"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="de.FuNIID3X.plta.MainActivity"
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=".Activity_Lektionen" />
<activity android:name=".Activity_Vokabeln" />
<activity android:name=".Activity_Formen" />
</application>
</manifest>
activity_main.xml
Code:
<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:background="@drawable/bg"
tools:context=".MainActivity" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/Lektionen"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="@+id/Vokabeln"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="@+id/Formen"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
MainActivity.java
Code:
package de.FuNIID3X.plta;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
// Tab for Lektionen
TabSpec lektionenspec = tabHost.newTabSpec("Lektionen");
// setting Title and Icon for the Tab
lektionenspec.setIndicator("Lektionen", getResources().getDrawable(R.drawable.bg));
Intent lektionenIntent = new Intent(this, LektionenActivity.class);
lektionenspec.setContent(lektionenIntent);
// Tab for Vokabeln
TabSpec vokabelnspec = tabHost.newTabSpec("Vokabeln");
vokabelnspec.setIndicator("Vokabeln", getResources().getDrawable(R.drawable.bg));
Intent vokabelnIntent = new Intent(this, VokabelnActivity.class);
vokabelnspec.setContent(vokabelnIntent);
// Tab for Formen
TabSpec formenspec = tabHost.newTabSpec("Formen");
formenspec.setIndicator("Formen", getResources().getDrawable(R.drawable.bg));
Intent formenIntent = new Intent(this, FormenActivity.class);
formenspec.setContent(formenIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(lektionenspec); // Adding lektionen tab
tabHost.addTab(vokabelnspec); // Adding vokabeln tab
tabHost.addTab(formenspec); // Adding formen tab
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}