Parcelable say that the CREATOR field should be static, but when I try to implement it this way, I get the error "Inner classes cannot have static declarations."
I tried to resolve this by placing my CategoryButton in a separate class (without declaring it an inner class in MainActivity ), but then I could not call getApplicationContext() in the constructor to go to super.
public class MainActivity extends ActionBarActivity { private class CategoryButton extends Button implements Parcelable{ private ArrayList<CategoryButton> buttons = null; private RelativeLayout.LayoutParams params = null; public CategoryButton(Context context){ super(context); }; public void setButtons(ArrayList<CategoryButton> buttons){ this.buttons = buttons; } public void setParams(RelativeLayout.LayoutParams params){ this.params = params; } public ArrayList<CategoryButton> getButtons(){ return this.buttons; } public RelativeLayout.LayoutParams getParams(){ return this.params; } public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) { out.writeList(buttons); } public static final Parcelable.Creator<CategoryButton> CREATOR
source share