Thanks, Chenna, for your reply;

but I have some doubts more... Could you better explain me , with
sample code?

You say: "Declare your activity as abstract class in library"  => ok,
in this way (right?)

**************************************************************************
public abstract class SecondLibraryActivity extends Activity{

         @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.second_activity);

                TextView t = (TextView) findViewById(R.id.textView);

                t.setText("Hello, i'm second activity on library!!!");
            }
}
**************************************************************************



then, "create a new activity in client apps using that library.": =>
like this (right?)

*************************************************************************
public class SecondLibraryActivity extends Activity{

         @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.second_activity);

                TextView t = (TextView) findViewById(R.id.textView);

                t.setText("Hello, i'm second activity on project!!!");
            }

}
*************************************************************************

now, in Manifest Project, which activity must I declare ???

* if a refer to project activity :
<application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity
android:name="com.nolanofra.app.androidLibraryExample.AndroidLibraryExampleActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

                <activity android:name=".SecondLibraryActivity">
        </activity>

    </application>

then I have an arror in AndroidLibraryExampleActivity at line:
Intent intent = new Intent(AndroidLibraryExampleActivity.this,
SecondLibraryActivity.class);

with ActivityNotFoundException;


* if I refer to library activity:

 <activity
android:name="com.nolanofra.app.androidLibraryExample.AndroidLibraryExampleActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

                <activity
android:name="com.nolanofra.app.androidLibraryExample.SecondLibraryActivity">
        </activity>

then it will be run always code of library activity.

I don' t understand when you say: "Declare a configuration class with
static variables for your library. Assign resource ids with your local
R.ids ..."
Could you explain me with an example?

Thanks for you patience,
francesco

On 26 Ott, 14:29, Chenna <[email protected]> wrote:
> Declare your activity as abstract class in library and create a new
> activity in client apps using that library.
>
> Declare a configuration class with static variables for your library.
> Assign resource ids with your local R.ids. If required you can allow
> yr client apps can configure required resources for the same.
>
> hope this helps.
>
> thanks
> Chenna
>
> On Oct 26, 2:18 pm, Francesco <[email protected]> wrote:
>
> > hi all,
>
> > this is my situation: i have a library project, and a project
> > referencing it. I know that is very simple to redefine any resource in
> > my project, because in cases where a resource ID is defined in both
> > the application and the library, the tools ensure that the resource
> > declared in the application gets priority and that the resource in the
> > library project is not compiled into the application .apk ( from
> > android developers web site ).
>
> > But: how can i do to redefine source (for example, override an
> > activity) in my project?
>
> > I have implemented some code samples, to better explain my problem:
>
> > In my library project, i have two activities:
>
> > *AndroidLibraryExampleActivity:
> > ********************************************************************
>
> > package com.nolanofra.app.androidLibraryExample;
>
> > import android.app.Activity;
> > import android.content.Intent;
> > import android.os.Bundle;
> > import android.view.View;
>
> > public class AndroidLibraryExampleActivity extends Activity {
> > /** Called when the activity is first created. */
> > @Override
> > public void onCreate(Bundle savedInstanceState) {
> >     super.onCreate(savedInstanceState);
> >     setContentView(R.layout.main);
>
> > }
>
> > public void onSecondActivityGo (View v)
> > {
> >     Intent intent = new Intent(AndroidLibraryExampleActivity.this,
> > SecondLibraryActivity.class);
>
> >     startActivity(intent);}
>
> > *************************************************************************** 
> > *******************
>
> >  and SecondLibraryActivity:
> > **************************************************************
>
> > package com.nolanofra.app.androidLibraryExample;
>
> > import android.app.Activity;
> > import android.os.Bundle;
> > import android.widget.TextView;
>
> > public class SecondLibraryActivity extends Activity{
>
> >      @Override
> >         public void onCreate(Bundle savedInstanceState) {
> >             super.onCreate(savedInstanceState);
> >             setContentView(R.layout.second_activity);
>
> >             TextView t = (TextView) findViewById(R.id.textView);
>
> >             t.setText("Hello, i'm second activity on library!!!");
> >         }}
>
> > *************************************************************************** 
> > *******************
>
> > Manifest of library project is:
> > ************************************************************
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >       package="com.nolanofra.app.androidLibraryExample"
> >       android:versionCode="1"
> >       android:versionName="1.0">
> >     <uses-sdk android:minSdkVersion="8" />
>
> >     <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> >         <activity android:name=".AndroidLibraryExampleActivity"
> >                   android:label="@string/app_name">
> >         </activity>
>
> >         <activity android:name=".SecondLibraryActivity"
> >                   android:label="@string/app_name">
> >         </activity>
>
> >     </application>
> > </manifest>
> > *************************************************************************** 
> > **********************
>
> > In my project referencing library, I want to redefine
> > SecondLibraryActivity  in order to change text displayed in text view,
> > for example I would like to do some of this:
>
> > package com.nolanofra.app.sampleProjectUsingLibrary;
>
> > import android.app.Activity;
> > import android.os.Bundle;
> > import android.widget.TextView;
>
> > import com.nolanofra.app.androidLibraryExample.R;
>
> > public class SecondLibraryActivity extends Activity{
>
> >      @Override
> >         public void onCreate(Bundle savedInstanceState) {
> >             super.onCreate(savedInstanceState);
> >             setContentView(R.layout.second_activity);
>
> >             TextView t = (TextView) findViewById(R.id.textView);
>
> >             t.setText("Hello, i'm second activity on project!!!");
> >         }
>
> > }
>
> > *************************************************************************** 
> > ************
>
> > Android Manifest on project is:
> > **************************************************
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >       package="com.nolanofra.app.sampleProjectUsingLibrary"
> >       android:versionCode="1"
> >       android:versionName="1.0">
> >     <uses-sdk android:minSdkVersion="8" />
>
> >     <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> >         <activity
> > android:name="com.nolanofra.app.androidLibraryExample.AndroidLibraryExample 
> > Activity">
> >             <intent-filter>
> >                 <action android:name="android.intent.action.MAIN" />
> >                 <category
> > android:name="android.intent.category.LAUNCHER" />
> >             </intent-filter>
> >         </activity>
>
> >         <activity
> > android:name="com.nolanofra.app.androidLibraryExample.SecondLibraryActivity 
> > ">
> >         </activity>
>
> >     </application>
> > </manifest>
> > *************************************************************************** 
> > ***********************************
>
> > So, how can I do that ? Is it possible to overwrite, in my project,
> > the activity declared in the library in order to change its behavior?
>
> > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to