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

是的,您必須添加啓動程序的清單文件項目也 –