我正在尝试做一个使用标签的应用程序。我遵循这个教程:http: //mobileorchard.com/android-app-development-tabbed-activities/
我成功地使用一项活动完成了一个选项卡,但我的问题是当我尝试使用一些活动来完成该部分时。
我从android开始,你能帮帮我吗?你能说我用的方法好不好?(对不起我的英语^^)
在应用程序意外停止之前,我遇到了错误:
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)
我的 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>
我的 tabManage.java:它应该将我的 accueil_mobile 活动“放在”第一个选项卡中,并将标识放在
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);
}
}
我的 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>
我的 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);
}
}
我的 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>