Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:06:21+00:00 2026-05-24T12:06:21+00:00

I am fairly new to Java programming and was following a tutorial located here:

  • 0

I am fairly new to Java programming and was following a tutorial located here: http://coenraets.org/blog/android-samples/androidtutorial/
Where I copied the code I am having a problem with here: http://code.google.com/p/androidtutorial/source/browse/trunk/%20androidtutorial/EmployeeDirectory6/src/samples/employeedirectory/EmployeeDetails.java

EDIT: Thank You all. Thanks to @adamcodes for pointing out I totally missed that link where he put out the source code. It looks like he forgot to include that link in the step by step tutorial.

At about 25 lines down I’m getting an error at

protected ArrayList<EmployeeAction> actions;

which says “EmployeeAction cannot be resolved to a type” My question is does the class EmployeeAction have to be created

actions = new ArrayList<EmployeeAction>();

Even if I put “actions = new ArrayList();” in my code? If so what should the class contain?

package samples.employeedirectory;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class EmployeeDetails extends ListActivity {

protected TextView employeeNameText;
protected TextView titleText;
protected ArrayList<EmployeeAction> actions;
protected EmployeeActionAdapter adapter;
protected int employeeId;
protected int managerId;

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

    employeeId = getIntent().getIntExtra("EMPLOYEE_ID", 0);
    SQLiteDatabase db = (new DatabaseHelper(this)).getWritableDatabase();
    Cursor cursor = db.rawQuery("SELECT emp._id, emp.firstName, emp.lastName, emp.title, emp.officePhone, emp.cellPhone, emp.email, emp.managerId, mgr.firstName managerFirstName, mgr.lastName managerLastName FROM employee emp LEFT OUTER JOIN employee mgr ON emp.managerId = mgr._id WHERE emp._id = ?", 
                            new String[]{""+employeeId});

    if (cursor.getCount() == 1)
    {
            cursor.moveToFirst();

            employeeNameText = (TextView) findViewById(R.id.employeeName);
            employeeNameText.setText(cursor.getString(cursor.getColumnIndex("firstName")) + " " + cursor.getString(cursor.getColumnIndex("lastName")));

            titleText = (TextView) findViewById(R.id.title);
            titleText.setText(cursor.getString(cursor.getColumnIndex("title")));

            actions = new ArrayList<EmployeeAction>();

            String officePhone = cursor.getString(cursor.getColumnIndex("officePhone"));
            if (officePhone != null) {
                    actions.add(new EmployeeAction("Call office", officePhone, EmployeeAction.ACTION_CALL));
            }

            String cellPhone = cursor.getString(cursor.getColumnIndex("cellPhone"));
            if (cellPhone != null) {
                    actions.add(new EmployeeAction("Call mobile", cellPhone, EmployeeAction.ACTION_CALL));
                    actions.add(new EmployeeAction("SMS", cellPhone, EmployeeAction.ACTION_SMS));
            }

            String email = cursor.getString(cursor.getColumnIndex("email"));
            if (email != null) {
                    actions.add(new EmployeeAction("Email", email, EmployeeAction.ACTION_EMAIL));
            }

            managerId = cursor.getInt(cursor.getColumnIndex("managerId"));
            if (managerId>0) {
                    actions.add(new EmployeeAction("View manager", cursor.getString(cursor.getColumnIndex("managerFirstName")) + " " + cursor.getString(cursor.getColumnIndex("managerLastName")), EmployeeAction.ACTION_VIEW));
            }

            cursor = db.rawQuery("SELECT count(*) FROM employee WHERE managerId = ?", 
                                    new String[]{""+employeeId});
            cursor.moveToFirst();
            int count = cursor.getInt(0);
            if (count>0) {
                    actions.add(new EmployeeAction("View direct reports", "(" + count + ")", EmployeeAction.ACTION_REPORTS));
            }

            adapter = new EmployeeActionAdapter();
            setListAdapter(adapter);
    }

}

public void onListItemClick(ListView parent, View view, int position, long id) {

        EmployeeAction action = actions.get(position);

        Intent intent;
        switch (action.getType()) {

            case EmployeeAction.ACTION_CALL:  
                    Uri callUri = Uri.parse("tel:" + action.getData());  
                    intent = new Intent(Intent.ACTION_CALL, callUri); 
                startActivity(intent);
                    break;

            case EmployeeAction.ACTION_EMAIL:  
            intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[]{action.getData()});
            startActivity(intent);
            break;

            case EmployeeAction.ACTION_SMS:  
                    Uri smsUri = Uri.parse("sms:" + action.getData());  
                    intent = new Intent(Intent.ACTION_VIEW, smsUri); 
                startActivity(intent);
                    break;

            case EmployeeAction.ACTION_REPORTS:  
                    intent = new Intent(this, DirectReports.class);
                    intent.putExtra("EMPLOYEE_ID", employeeId);
                    startActivity(intent);
                    break;

            case EmployeeAction.ACTION_VIEW:  
                    intent = new Intent(this, EmployeeDetails.class);
                    intent.putExtra("EMPLOYEE_ID", managerId);
                    startActivity(intent);
                    break;
        }
}    

class EmployeeActionAdapter extends ArrayAdapter<EmployeeAction> {

    EmployeeActionAdapter() {
                    super(EmployeeDetails.this, R.layout.action_list_item, actions);
            }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
            EmployeeAction action = actions.get(position);
            LayoutInflater inflater = getLayoutInflater();
            View view = inflater.inflate(R.layout.action_list_item, parent, false);
            TextView label = (TextView) view.findViewById(R.id.label);
            label.setText(action.getLabel());
            TextView data = (TextView) view.findViewById(R.id.data);
            data.setText(action.getData());
            return view;
    }

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:06:21+00:00Added an answer on May 24, 2026 at 12:06 pm

    Java is statically typed, and everything you want to refer to at compile time needs to exist. So yes – you have to create the EmployeeAction, if you need it. (And you need to import it with import yourpackage.EmployeeAction; at the top of the class)

    The type definition if the list <EmployeeAction> is there to enforce compile time safety for the elements of the list. It means “you can only put instances of EmployeeAction in this collection”. This is useful when later you access the collection – the compiler can guarantee that the list contains only EmployeeAction instances

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new in Android/Java programming, so some of the basic stuff is still
I'm fairly new to Android programming and to Java in general, but I have
I have been working on Eclipse recently. I am fairly new to java programming,
I'm fairly new to programming and new to java, but I'd like to jump
I'm a fairly new to Java and to programming, so excuse me if this
I am fairly new to web programming, I have mainly used java to create
I am still fairly new to Java programming and I was looking over a
I'm comfortable programming in Java, but am fairly new to Spring. I've been reading
I am fairly new to programming in both Java and C and need some
I'm fairly new to Java (been writing other stuff for many years) and unless

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.