ArrayList<Polygon>
usingを渡そうとしていintent.putExtra()
ます。
シリアル化可能なオブジェクト (name=Polygon.polygon) の書き込みでIOExceptionが発生します。
Polygon は私が作成したクラスで、このクラスに Serializable を実装しています。
Intent intent = new Intent(this, Main.class);
intent.putExtra("polygons", (ArrayList<Polygon>)this.polygons);
startActivity(intent);
Polygon クラスにはArrayList<Point>
、いくつかの getter と setter を持つ多角形のポイントのリストを保持する があります。それだけです。Polygon クラスに Serializable を実装しましたが、上記のコードから例外が発生しています。
public class Polygon implements Serializable{
ArrayList<Point> polygon;
public Polygon(){
polygon = new ArrayList();
}
public int getSize(){
return polygon.size();
}
public ArrayList<Point> getPointArray(){
return this.polygon;
}
public void addPoint(int x, int y, int mapWidth, int mapHeight, int canvasWidth, int canvasHeight){
//going to scale up here
float scaleX = mapWidth / canvasWidth;
float scaleY = mapHeight / canvasHeight;
polygon.add(new Point((int)(x*scaleX),(int)(y*scaleY)));
}
public void removePoint(int index){
polygon.remove(index);
}
}
何か案は?