Question

I'm trying to do an app which use Tabs. I follow this tuto: http://mobileorchard.com/android-app-development-tabbed-activities/

I succeeded to do a tab using one activity, but my problem is when I try to do the part using some activities.

I begin with android, could you help me ? Could you say me if the way I use to do it is good ? (sorry for my english ^^)

Before the app stopped unexpectedly I have the error:

04-22 14:12:39.786: E/AndroidRuntime(319): FATAL EXCEPTION: main
04-22 14:12:39.786: E/AndroidRuntime(319): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.joignabilite/com.example.joignabilite.TabManage}; have you declared this activity in your AndroidManifest.xml?
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.app.Activity.startActivityForResult(Activity.java:2827)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.app.Activity.startActivity(Activity.java:2933)
04-22 14:12:39.786: E/AndroidRuntime(319):  at com.example.joignabilite.Identification$1.onClick(Identification.java:25)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.view.View.performClick(View.java:2485)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.view.View$PerformClick.run(View.java:9080)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.os.Handler.handleCallback(Handler.java:587)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.os.Looper.loop(Looper.java:123)
04-22 14:12:39.786: E/AndroidRuntime(319):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-22 14:12:39.786: E/AndroidRuntime(319):  at java.lang.reflect.Method.invokeNative(Native Method)
04-22 14:12:39.786: E/AndroidRuntime(319):  at java.lang.reflect.Method.invoke(Method.java:507)
04-22 14:12:39.786: E/AndroidRuntime(319):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-22 14:12:39.786: E/AndroidRuntime(319):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-22 14:12:39.786: E/AndroidRuntime(319):  at dalvik.system.NativeStart.main(Native Method)

My tab_manage.xml:

<?xml version="1.0" encoding="utf-8"?>

<TabHost android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@android:id/tabhost"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TabWidget
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@android:id/tabs"/>
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </FrameLayout>
</TabHost>

My tabManage.java: It should "put" my accueil_mobile activity in the first tab and the identification in the

package com.example.joignabilite;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

@SuppressWarnings("deprecation")
public class TabManage extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab_manage);

        TabHost tabHost=(TabHost)findViewById(android.R.id.tabhost);
        tabHost.setup();   

        //First Tab
        TabSpec spec1=tabHost.newTabSpec("Mobile");
        Intent in1=new Intent(this, AccueilMobile.class);
        spec1.setContent(in1);
        // Second Tab
        TabSpec spec2=tabHost.newTabSpec("Fixe");
        Intent in2=new Intent(this, Identification.class);
        spec2.setContent(in2);

        tabHost.addTab(spec1);
        tabHost.addTab(spec2);
    }
}

My accueil_mobile.xml:

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="horizontal"
    tools:context=".Identification" >

    <include android:id="@+id/header"
         layout="@layout/header"
         android:layout_height="wrap_content"
         android:layout_width="fill_parent"/>

    <Button android:id="@+id/choix_transfert"
        android:layout_width="@dimen/button_width"
        android:layout_height="@dimen/button_height"
        android:layout_below="@+id/header"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="80dp"
        android:background="@drawable/buttontype1"
        android:text="@string/Transfert" />
    <Button android:id="@+id/choix_filtrage"
        android:layout_width="@dimen/button_width"
        android:layout_height="@dimen/button_height"
        android:layout_below="@+id/header"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="160dp"
        android:background="@drawable/buttontype1"
        android:text="@string/Filtrage" />
    <Button android:id="@+id/choix_parametres"
        android:layout_width="@dimen/button_width"
        android:layout_height="@dimen/button_height"
        android:layout_below="@+id/header"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="240dp"
        android:background="@drawable/buttontype1"
        android:text="@string/Parametres" />

</RelativeLayout>

My AccueilMobile.java:

package com.example.joignabilite;

import android.app.Activity;
import android.os.Bundle;

public class AccueilMobile extends Activity{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.accueil_mobile);

    }
}

My acivity_identification.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/blue"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/connexion_picture"
        android:layout_width="120dp"
        android:layout_height="60dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="@dimen/normal_padding"
        android:src="@drawable/logo2"
        android:contentDescription="@string/BT" />

    <Button
        android:id="@+id/create_account"
        android:layout_width="@dimen/small_button_width"
        android:layout_height="@dimen/button_height"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/normal_padding"
        android:background="@drawable/buttontype1"
        android:text="@string/create_account" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:paddingTop="@dimen/normal_padding"
        android:text="@string/email"
        android:textSize="@dimen/normal_text_size" />

    <EditText
        android:id="@+id/user_email"
        android:layout_width="@dimen/large_padding"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:layout_gravity="center" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:paddingTop="@dimen/normal_padding"
        android:textSize="@dimen/normal_text_size"
        android:text="@string/password" />

    <EditText
        android:id="@+id/user_password"
        android:layout_width="@dimen/large_padding"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:inputType="textPassword" />

    <Button
        android:id="@+id/connect"
        android:layout_width="@dimen/small_button_width"
        android:layout_height="@dimen/button_height"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/normal_padding"
        android:background="@drawable/buttontype1"
        android:text="@string/connect" />

</LinearLayout>
Was it helpful?

Solution

The answer is in the second line of your stacktrace. You've apparently haven't defined your Activity in AndroidManifest.xml

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top