Android如何为所有类和活动使用单数组列表?

Android如何为所有类和活动使用单数组列表?,android,google-maps,arraylist,overlay,Android,Google Maps,Arraylist,Overlay,在我的应用程序中,我使用googlemaps进行一项主要活动,并在googlemaps上为一个叠加类进行徒手素描。对于此徒手绘制的存储路径,在overlay类中使用了一个数组列表。下一步是在主活动中执行撤消和重做功能,所以我必须在主活动中使用数组列表,因为我要将覆盖类中的数组列表声明为公共静态。由于使用了static,我得到了连续绘图,这是我的问题。。如何在我的应用程序中使用数组列表而不使用静态 public class HandDrawOverlay extends Overlay {

在我的应用程序中,我使用googlemaps进行一项主要活动,并在googlemaps上为一个叠加类进行徒手素描。对于此徒手绘制的存储路径,在overlay类中使用了一个数组列表。下一步是在主活动中执行撤消和重做功能,所以我必须在主活动中使用数组列表,因为我要将覆盖类中的数组列表声明为公共静态。由于使用了static,我得到了连续绘图,这是我的问题。。如何在我的应用程序中使用数组列表而不使用静态

public class HandDrawOverlay extends Overlay {

   private boolean iseditMode = true;
   private boolean isTouched = false;
   private Paint paint = new Paint();
   private Point screenPt1 = new Point();
   private Point screenPt2 = new Point();
   public static ArrayList<GeoPoint> points = new ArrayList<GeoPoint>();    
   int x, y;
   GeoPoint geoP;
   HandDrawOverlay handDrawOverlay;
   private GoogleMapActivity mview = null;
   private boolean isUp = false;     

   public HandDrawOverlay(GoogleMapActivity mapviewdata){

      paint.setStrokeWidth(4.0f);
      paint.setStyle(Style.STROKE);
      paint.setColor(Color.BLUE);
      mview = mapviewdata;       
   }

   public static ArrayList<GeoPoint>  getBitmap(){
          return points;
   }   

   @Override
   public void draw(Canvas canvas, MapView mapView, boolean shadow) {    
    if (points != null && points.size() > 1) {           
        mapView.getProjection().toPixels(points.get(0), screenPt1);

        for (int i = 1; i < points.size(); i++) {            
            mapView.getProjection().toPixels(points.get(i), screenPt2);
            canvas.drawLine(screenPt1.x, screenPt1.y, screenPt2.x, screenPt2.y, paint);
            screenPt1.set(screenPt2.x, screenPt2.y);                 
        }
     }
  }

   @Override
   public boolean onTouchEvent(MotionEvent e, MapView mapView) {
    if(mview.isEditMode() && (iseditMode)){         

        x = (int) e.getX();
        y = (int) e.getY();           
        geoP = mapView.getProjection().fromPixels(x, y);    
        Log.i("", "geoP" +geoP);

        switch (e.getAction()) {
        case MotionEvent.ACTION_DOWN:                            
            isTouched = true;        
            points.add(geoP);                               
            break;              

        case MotionEvent.ACTION_MOVE:            
            if (isTouched = true)
                points.add(geoP);               
            break;

        case MotionEvent.ACTION_UP:          
            if (isTouched = true)
                points.add(geoP);                    
            isUp = true;
            handDrawOverlay = new HandDrawOverlay(mview);
            mapView.getOverlays().add(handDrawOverlay);
            break;
        }           
        mapView.postInvalidate();    
        return true;            
      }      
       return false;
   }     
}
公共类HandDrawOverlay扩展了覆盖{
私有布尔iseditMode=true;
私有布尔值isTouched=false;
私人油漆=新油漆();
专用点屏幕PT1=新点();
专用点屏幕PT2=新点();
public static ArrayList points=new ArrayList();
int x,y;
地质点;
手绘套印手绘套印;
私有GoogleMapActivity mview=null;
私有布尔值isUp=false;
公共HandDrawOverlay(GoogleMapActivity mapviewdata){
油漆。设置行程宽度(4.0f);
油漆.设置样式(样式.笔划);
油漆。设置颜色(颜色。蓝色);
mview=mapviewdata;
}
公共静态ArrayList getBitmap(){
返回点;
}   
@凌驾
公共空白绘制(画布、地图视图、地图视图、布尔阴影){
如果(points!=null&&points.size()>1){
mapView.getProjection().toPixels(points.get(0),screenPt1);
对于(inti=1;i
为此,您可以使用此选项

public class Hiroshima {

    private static Hiroshima hr = new Hiroshima();


    public ArrayList<String> mImages = new ArrayList<String>();


      private Hiroshima(){}

      public static Hiroshima getInstance(){

          return hr;
      }

}

hx是该类的参考。要使用ArrayList,您必须编写hx.mImages.ur的代码正在运行。。。但我们遇到了同样的问题,得到连续绘图。。。。就像以前我使用的数组列表作为静态数组一样。。。
Hiroshima hx = Hiroshima.getInstance();