0

我试图访问图书馆活动到另一个项目(在tabhost 和每个标签调用不同的活动。),但其抛异常访问图书馆活动无法在另一个项目

Caused by: android.content.ActivityNotFoundException: Unable to find 
explicit activity class 
{com.themontcalm.droid.activity/com.themontcalm.droid.lib.activity.ReservationTab}; 
have you declared this activity in your AndroidManifest.xml? 

其中: - com.themontcalm.droid.lib.activity.ReservationTab是一个 图书馆项目。而com.themontcalm.droid.activity发射 项目我在哪里访问图书馆活动

代码我在哪里访问我的项目库:---

package com.themontcalm.droid.activity; 

import android.app.TabActivity; 
import android.content.Intent; 
import android.content.res.Resources; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.ImageButton; 
import android.widget.TabHost; 


public class HomeScreen extends TabActivity implements OnClickListener { 
    TabHost tabHost; 
    ImageButton location, contacts, explore; 
    Intent intent; 
    //LocationGB locationActivity = new LocationGB(); 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_home_screen); 
    //LocationFactory.getInstance().setLocationActivity(LocationGB.class); 

     // addListenerOnButton(); 
     location = (ImageButton) findViewById(R.id.location); 
     contacts = (ImageButton) findViewById(R.id.contacts); 
     explore = (ImageButton) findViewById(R.id.explore); 

     location.setOnClickListener(this); 
     contacts.setOnClickListener(this); 
     explore.setOnClickListener(this); 
     Resources res = getResources(); // Resource object to get Drawables 
     // The activity TabHost 
     TabHost.TabSpec spec; // Reusable TabSpec for each tab 
     Intent intent; // Reusable Intent for each tab 

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

     // Create an Intent to launch an Activity for the tab (to be reused) 

     intent = new Intent().setClass(getBaseContext(), com.themontcalm.droid.lib.activity.ReservationTab.class); 
     spec = tabHost.newTabSpec("RESERVATION") 
       .setIndicator("", res.getDrawable(R.drawable.testing))// , 
                     // res.getDrawable(R.drawable.testing) 
       .setContent(intent); 

     tabHost.addTab(spec); 

     // Do the same for the other tabs 

     intent = new Intent().setClass(this, com.themontcalm.droid.lib.activity.GalleryTabActivity.class); 
     spec = tabHost.newTabSpec("MODIFY") 
       .setIndicator("", res.getDrawable(R.drawable.testing))// ,res.getDrawable(R.drawable.testing) 
       .setContent(intent); 
     tabHost.addTab(spec); 

     intent = new Intent().setClass(this, com.themontcalm.droid.lib.activity.VideoTabActivity.class); 
     spec = tabHost.newTabSpec("VIDEO") 
       .setIndicator("", res.getDrawable(R.drawable.testing))// , 
                     // res.getDrawable(R.drawable.testing) 
       .setContent(intent); 
     tabHost.addTab(spec); 

     // set tab which one you want open first time 0 or 1 or 2 
     tabHost.setCurrentTab(0); 

    } 

    @Override 
    public void onClick(View v) { 
     // TODO Auto-generated method stub 
     if (v == location) { 
    // intent = new Intent(HomeScreen.this, LocationGB.class); 
    //  HomeScreen.this.startActivity(intent); 
     } else if (v == contacts) { 
      intent = new Intent(HomeScreen.this, com.themontcalm.droid.lib.activity.ContactInfo.class); 
      HomeScreen.this.startActivity(intent); 
     } else if (v == explore) { 
      intent = new Intent(HomeScreen.this, com.themontcalm.droid.lib.activity.ExplorePropertyActivity.class); 
      HomeScreen.this.startActivity(intent); 
     } 

    } 

} 
+1

您是否将lib项目属性设置为“is library”?你是否在你的主项目中包含了你的lib项目? – KOTIOS

+0

是的,并且已经在启动器项目 –

+0

中添加了,同时指出它必须要求导入的类名称是否做到这一点? – KOTIOS

回答

2

我怀疑,清单文件<activity>标记声明会起作用,但 给一个尝试,做包括此清单文件:

<uses-library android:name="com.themontcalm.droid.lib.activityr" 
android:required="true" /> 
+0

在你的主项目中声明你的活动与它的包名 – KOTIOS

+0

我做到了这一点,它的工作我把所有的活动声明放在启动项目清单文件和它的工作......我想知道为什么.... –

0

您应该声明你的com.themontcalm.droid.lib.activity。您当前项目中的ReservationTab库。要做到这一点,

  1. 去属性,然后Android,下面有库部分,点击添加按钮,并选择你的库。
  2. 就是在eclipse得到更新之前,现在你也应该去Java Built Path并选择你的库。
+0

我做了这些过程。 ..它也抛出错误: - MontcalmLibs]找不到MontcalmLibs.apk! –

+0

可以肯定的是,您清理并重建项目的权利? – yahya

+0

我已经清理了我的启动项目和图书馆项目几次它并没有帮助我... –

0

确保您将库项目链接为库而不是外部jar。请转至项目properties > Android > Library,然后单击添加库。

然后当你正在做的项目清单定义活动

<activity 
     android:label="@string/app_name" 
     android:name="fullpath.LibraryProjectActivity" >  
</activity> 
+0

我可能必须在启动项目中定义库活动,我正在访问它 –

+0

是的,您必须添加启动程序的清单文件项目也 –