English 中文(简体)
援引Android图书馆(.jar)的活动?
原标题:Invoking an activity from Android Library(.jar)?

我创建了一个 Android 图书馆项目, 包含多项活动。 我想在其他项目中重新使用这些活动。 我该怎么做呢? 我补充了这个项目 vi:

项目 & gt; Adroid- & gt; Add (Android 图书馆项目) 。

然后在Android Profession文件中添加了所需的细节。

Adroid 表现文件 :

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.testlib.com"
        android:versionCode="1"
        android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="9" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-libraryandroid:name="org.mainlib.com" android:required="true"/>
    <application android:icon="@drawable/ic_launcher" 
        android:label="@string/app_name" >
        <activity android:name=".TestLibActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="org.mainlib.com.MainActivity"/>                 
    </application>    
</manifest>

启动活动的代码 :

Intent myintent=new Intent(v.getContext(),MainActivity.class);
startActivityForResult(myintent, 0);

我怎样才能从我的罐子档案中援引一项活动呢?

问题回答

我不明白你的问题 你的意思是

如何从图书馆外部启动测试Lib 活动

?????

If that s the case, you can call it by calling Intent myintent=new Intent(v.getContext(),org.testlib.com.TestLibActivity.class); startActivityForResult(myintent, 0);

当然,您必须在活动中添加正确的导入内容,并将图书馆添加到您的项目中。

如果您创建了一个机器人库, 并正确添加了它( 看起来像它) 。 那么唯一能做的就是与正常活动一样。 唯一的区别在于您从您的图书馆工程导入一条路径, 而不是您自己的工程 。

另请注意,您不需要在列表中添加图书馆。您只需通过项目属性添加图书馆项目。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签