JackD
JackD

Reputation: 43

How to call a Java class from an Android activity?

This may sound like a question asked by another user, but the solution does not work for me so I would like to try asking about my code.

I have created a folder under the res directory that contains some java classes I would like to reference/ call from one of my Activities but the import does not work and the classes do not seem to be recognised.

Calling code in the Activity file:

//    Method to populate the screen with images

public void initializeWithCGImages(){

    ArrayList<src.cercia.batik.app.DesignUnitViewer> mapviewers,viewerList;
    ArrayList<src.cercia.batik.geometry.Population> populations;


    src.cercia.batik.app.InitializePopulation initialize=new src.cercia.batik.app.InitializePopulation();
    populations = initialize.getInitialGenes();
    mapviewers=new ArrayList<cercia.batik.app.DesignUnitViewer>();
...
}

Code for the reference in folder: "res/src/cercia/batik/app":

package cercia.batik.app;

import cercia.batik.geometry.Population;

public class InitializePopulation {
        public InitializePopulation(){

}
...
}

Upvotes: 1

Views: 305

Answers (1)

CaseyB
CaseyB

Reputation: 25058

The res directory is for resources. Things like imaged and layouts. The compiler isn't going to look there for Java files. Move them up into your java folder.

Upvotes: 1

Related Questions