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

  • SEARCH
  • Home
  • 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 7410117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:11:02+00:00 2026-05-29T06:11:02+00:00

I’m attempting to create a Parcelable class in Android so that I can pass

  • 0

I’m attempting to create a Parcelable class in Android so that I can pass a ArrayList of these objects between Activities. I’ve followed very closely the examples found here on StackOverflow (http://stackoverflow.com/questions/6201311/how-to-read-write-a-boolean-when-implementing-the-parcelable-interface)and in the Android docs (http://developer.android.com/reference/android/os/Parcelable.html), but I keep getting an error on the required static field CREATOR: The field CREATOR cannot be declared static; static fields can only be declared in static or top level types

I get this error on my class, as well as the example class cut/pasted directly from the Android docs. There must be something unique to my situation that I’m not aware of….?? My class is given below. Any ideas?

Thanks,

Bryan

public class ComplaintType implements Parcelable
{
    // class data
    private int groupID = 0;
    private int id = 0;
    private String description = "";
    private boolean checked = false; // does this complaint type apply to this patient?

    // constructors
    public ComplaintType() {}       
    public ComplaintType(int _groupID, String desc, int _id, boolean ckd) {
        this.groupID = _groupID;
        this.description = desc; 
        this.id = _id;
        this.checked = ckd;}

    // getters/setters
    public int getGroupID() {return groupID;}
    public void setGroupID(int _groupID) { this.groupID = _groupID;}
    public String getDesc() {return description;}
    public void setDesc(String desc) {this.description = desc;}
    public int getID() {return id;}
    public void setID(int _id) {this.id = _id;}
    public boolean isChecked() {return checked;}
    public void setChecked(boolean ckd) {this.checked = ckd;}

    // utility functions
    public String toString() {return this.description;}
    public void toggleChecked() {checked = !checked;}

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(groupID);
        dest.writeInt(id);
        dest.writeString(description);
        dest.writeByte((byte) (checked ? 1 : 0));  // convert byte to a boolean (1=true, 0=false)
    }

    public static final Parcelable.Creator<ComplaintType> CREATOR // <-- ERROR OCCURS HERE
     = new Parcelable.Creator<ComplaintType>() {

        public ComplaintType createFromParcel(Parcel in){
            ComplaintType complaint = new ComplaintType();
            complaint.setGroupID(in.readInt());
            complaint.setID(in.readInt());
            complaint.setDesc(in.readString());
            complaint.setChecked(in.readByte() == 1);  // store the boolean as a byte (1=true, 0=false)
            return complaint;
        }

        @Override
        public ComplaintType[] newArray(int size) {             
            return new ComplaintType[size];
        }
    };

}
  • 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-29T06:11:03+00:00Added an answer on May 29, 2026 at 6:11 am

    Sounds like your class is being declared non-static inside another class, which is why it’s not allowed to have static data members. Either make it a top-level class, or declare it static.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
Does anyone know how can I replace this 2 symbol below from the string

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.