如何声明两个包与他们的Andr​​oid清单文件中的活动?他们的、清单、声明、两个

2023-09-05 23:51:59 作者:小小拖油瓶

我的两个包在我的Andr​​oid应用程序。如何提这些不同的数据包以及它们在Android清单文件的活动呢?在我的code我已为

I have two packages in my android application. How to mention those different packages along with their activities in android manifest file?In my code I have given as

<manifest package="com.tabwidget">
    <application>
        <activity android:name=".com.tabwidget.Tab"></activity>
        <activity android:name=".com.tabwidget.TabHostProvider"></activity>
        <activity android:name=".com.tabwidget.TabView"></activity>
    </application>
</manifest>                  
<manifest package="com.kpbird.tabbarcontrol">
    <application>
        <activity android:name=".com.kpbird.tabbarcontrol.TabbarView"></activity>
    </application>
</manifest>

但我得到的异常无法找到明确的活动课...........如果是我错了?请帮我...........

But I am getting exception Unable to find explicit activity class ...........Where was i wrong? Please help me...........

推荐答案

看来你已经在XML犯了一些错误:

It seems you have made a few mistakes in the XML:

<manifest package="com.tabwidget">
    <application>

        1) BELOW: starting the names by "." means that
        you are implicitely extending the package prefix defined in the package 
        attribute of the manifest XML tag. 
        For example, if your package is "com.tabwidget", defining".MyActivity"
        will be interpreted as "com.tabwidget.MyActivity"
        By removing the first ".", you use an explicit notation instead:
        whatever your package is, "com.tabwidget.MyActivity" is interpreted
        as "com.tabwidget.MyActivity"
        <activity android:name=".com.tabwidget.Tab"></activity>
        <activity android:name=".com.tabwidget.TabHostProvider"></activity>
        <activity android:name=".com.tabwidget.TabView"></activity>
    </application>
</manifest>                  

2) BELOW: a manifest file should only contain one manifest XML tag:
<manifest package="com.kpbird.tabbarcontrol">
    <application>

        3) BELOW: same mistake as 1)
        <activity android:name=".com.kpbird.tabbarcontrol.TabbarView"></activity>
    </application>
</manifest>

接下来应该工作。它修复了这3个错误:

What follows should work. It fixes these 3 mistakes:

<manifest package="com.kpbird.tabbarcontrol">
    <application>
        <activity android:name="com.tabwidget.Tab"></activity>
        <activity android:name="com.tabwidget.TabHostProvider"></activity>
        <activity android:name="com.tabwidget.TabView"></activity>
        <activity android:name=".TabbarView"></activity>
    </application>
</manifest>